Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[browser][io] Workaround for issue MoveDirectory #40310

Merged
merged 2 commits into from
Aug 4, 2020
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)))
kjpou1 marked this conversation as resolved.
Show resolved Hide resolved
{
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