File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
library/std/src/sys/windows Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -1126,8 +1126,22 @@ pub fn unlink(p: &Path) -> io::Result<()> {
1126
1126
pub fn rename ( old : & Path , new : & Path ) -> io:: Result < ( ) > {
1127
1127
let old = maybe_verbatim ( old) ?;
1128
1128
let new = maybe_verbatim ( new) ?;
1129
- cvt ( unsafe { c:: MoveFileExW ( old. as_ptr ( ) , new. as_ptr ( ) , c:: MOVEFILE_REPLACE_EXISTING ) } ) ?;
1130
- Ok ( ( ) )
1129
+ let res =
1130
+ cvt ( unsafe { c:: MoveFileExW ( old. as_ptr ( ) , new. as_ptr ( ) , c:: MOVEFILE_REPLACE_EXISTING ) } ) ;
1131
+
1132
+ match res {
1133
+ Err ( ref e) if e. raw_os_error ( ) == Some ( c:: ERROR_CALL_NOT_IMPLEMENTED as i32 ) => {
1134
+ // 9x/ME doesn't support MoveFileEx, so we fall back to copy + delete and hope for the
1135
+ // best
1136
+ unsafe {
1137
+ cvt ( c:: CopyFileW ( old. as_ptr ( ) , new. as_ptr ( ) , c:: TRUE ) ) ?;
1138
+ cvt ( c:: DeleteFileW ( old. as_ptr ( ) ) ) ?;
1139
+ Ok ( ( ) )
1140
+ }
1141
+ }
1142
+ Err ( e) => Err ( e) ,
1143
+ Ok ( _) => Ok ( ( ) ) ,
1144
+ }
1131
1145
}
1132
1146
1133
1147
pub fn rmdir ( p : & Path ) -> io:: Result < ( ) > {
You can’t perform that action at this time.
0 commit comments