Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,19 @@ public static void MoveDirectory(string sourceFullPath, string destFullPath)
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();
Expand Down