File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
library/std/src/sys/windows Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -309,14 +309,16 @@ impl File {
309309 && unsafe { c:: GetLastError ( ) } == c:: ERROR_ALREADY_EXISTS
310310 {
311311 unsafe {
312- // Setting the allocation size to zero also sets the
313- // EOF position to zero.
314- let alloc = c:: FILE_ALLOCATION_INFO { AllocationSize : 0 } ;
312+ // This originally used `FileAllocationInfo` instead of
313+ // `FileEndOfFileInfo` but that wasn't supported by WINE.
314+ // It's arguable which fits the semantics of `OpenOptions`
315+ // better so let's just use the more widely supported method.
316+ let eof = c:: FILE_END_OF_FILE_INFO { EndOfFile : 0 } ;
315317 let result = c:: SetFileInformationByHandle (
316318 handle. as_raw_handle ( ) ,
317- c:: FileAllocationInfo ,
318- ptr:: addr_of!( alloc ) . cast :: < c_void > ( ) ,
319- mem:: size_of :: < c:: FILE_ALLOCATION_INFO > ( ) as u32 ,
319+ c:: FileEndOfFileInfo ,
320+ ptr:: addr_of!( eof ) . cast :: < c_void > ( ) ,
321+ mem:: size_of :: < c:: FILE_END_OF_FILE_INFO > ( ) as u32 ,
320322 ) ;
321323 if result == 0 {
322324 return Err ( io:: Error :: last_os_error ( ) ) ;
You can’t perform that action at this time.
0 commit comments