Compare commits

...

1 Commits

Author SHA1 Message Date
Ryan Walters
39a5df1ffd fix: use c-style strings instead of manual termination, cast pointer, use then_some 2025-09-02 08:52:08 -05:00
2 changed files with 4 additions and 3 deletions

View File

@@ -88,7 +88,7 @@ impl Platform {
handle => handle, handle => handle,
}; };
// Identify the file type of the handle // Identify the file type of the handle and whether it's 'well known' (i.e. we trust it to be a reasonable output destination)
let (well_known, file_type) = match unsafe { let (well_known, file_type) = match unsafe {
use windows::Win32::Foundation::HANDLE; use windows::Win32::Foundation::HANDLE;
GetFileType(HANDLE(handle)) GetFileType(HANDLE(handle))
@@ -107,7 +107,7 @@ impl Platform {
debug!("File type: {file_type:?}, well known: {well_known}"); debug!("File type: {file_type:?}, well known: {well_known}");
// If it's anything recognizable and valid, assume that a parent process has setup an output stream // If it's anything recognizable and valid, assume that a parent process has setup an output stream
Ok(well_known.then(|| file_type)) Ok(well_known.then_some(file_type))
} }
/// Try to attach to parent console /// Try to attach to parent console
@@ -128,7 +128,7 @@ impl Platform {
.map_err(|e| PlatformError::ConsoleInit(format!("Failed to attach to parent console: {:?}", e)))?; .map_err(|e| PlatformError::ConsoleInit(format!("Failed to attach to parent console: {:?}", e)))?;
let handle = unsafe { let handle = unsafe {
let pcstr = PCSTR::from_raw("CONOUT$\0".as_ptr()); let pcstr = PCSTR::from_raw(c"CONOUT$".as_ptr() as *const u8);
CreateFileA::<PCSTR>( CreateFileA::<PCSTR>(
pcstr, pcstr,
(GENERIC_READ | GENERIC_WRITE).0, (GENERIC_READ | GENERIC_WRITE).0,

View File

@@ -12,6 +12,7 @@ mod emscripten;
pub mod buffered_writer; pub mod buffered_writer;
pub mod tracing_buffer; pub mod tracing_buffer;
/// Cross-platform abstraction layer providing unified APIs for platform-specific operations. /// Cross-platform abstraction layer providing unified APIs for platform-specific operations.
pub trait CommonPlatform { pub trait CommonPlatform {
/// Platform-specific sleep function (required due to Emscripten's non-standard sleep requirements). /// Platform-specific sleep function (required due to Emscripten's non-standard sleep requirements).