* [browser][io] Workaround for issue MoveDirectory
- Issue workaround while waiting for emscripten fix. https://github.com/dotnet/runtime/issues/40305
- The following code checks for the existence of the source and destination directories which replaces the same code in the emscripten code.
emscripten tracking issue: https://github.com/emscripten-core/emscripten/issues/11804
* Update src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Unix.cs
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
throw new IOException(SR.Format(SR.IO_AlreadyExists_Name, destFullPath));
}
+#if TARGET_BROWSER
+ // renaming a file doesn't return correct error code on emscripten if one of the parent paths does not exist,
+ // manually workaround it for now (https://github.com/dotnet/runtime/issues/40305)
+ if (!Directory.Exists(Path.GetDirectoryName(sourceFullPath)))
+ {
+ throw new DirectoryNotFoundException(SR.Format(SR.IO_PathNotFound_Path, sourceFullPath));
+ }
+ if (!Directory.Exists(Path.GetDirectoryName(destFullPath)))
+ {
+ throw new DirectoryNotFoundException(SR.Format(SR.IO_PathNotFound_Path, destFullPath));
+ }
+#endif
+
if (Interop.Sys.Rename(sourceFullPath, destFullPath) < 0)
{
Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo();