File tree 1 file changed +3
-2
lines changed
1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ impl FilePath for File {
67
67
68
68
#[ cfg( windows) ]
69
69
fn path ( & self ) -> std:: io:: Result < PathBuf > {
70
+ use std:: ffi:: OsString ;
70
71
use std:: os:: windows:: { ffi:: OsStringExt , io:: AsRawHandle } ;
71
72
use windows:: Win32 :: {
72
73
Foundation ,
@@ -82,7 +83,7 @@ impl FilePath for File {
82
83
return Err ( io:: Error :: last_os_error ( ) ) ;
83
84
}
84
85
85
- let mut path = Vec :: with_capacity ( len as usize ) ;
86
+ let mut path = vec ! [ 0 ; len as usize ] ;
86
87
let len2 = unsafe {
87
88
let handle = Foundation :: HANDLE ( self . as_raw_handle ( ) ) ;
88
89
GetFinalPathNameByHandleW ( handle, & mut path, GETFINALPATHNAMEBYHANDLE_FLAGS ( 0 ) )
@@ -91,7 +92,7 @@ impl FilePath for File {
91
92
if len2 == 0 || len2 >= len {
92
93
return Err ( io:: Error :: last_os_error ( ) ) ;
93
94
}
94
- unsafe { path. set_len ( len2 as usize ) } ;
95
+ path. truncate ( len2 as usize ) ;
95
96
96
97
// Turn the \\?\UNC\ network path prefix into \\.
97
98
let prefix = [
You can’t perform that action at this time.
0 commit comments