Fix on Windows, renaming a file using the Directory class generates an incorrect exception
TEST=unit Bug: https://github.com/dart-lang/sdk/issues/47713 Change-Id: I603a452cece478ad5ddd85d47e9cfe02cee3f4d9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231801 Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Brian Quinlan <bquinlan@google.com>
This commit is contained in:
committed by
Commit Bot
parent
867e155ff6
commit
085e978ce4
@@ -508,6 +508,7 @@ bool Directory::Rename(Namespace* namespc,
|
||||
Utf8ToWideScope system_path(prefixed_dir);
|
||||
ExistsResult exists = ExistsHelper(system_path.wide());
|
||||
if (exists != EXISTS) {
|
||||
SetLastError(ERROR_FILE_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
const char* prefixed_new_dir = PrefixLongDirectoryPath(new_path);
|
||||
|
||||
@@ -141,7 +141,10 @@ testRenameButActuallyFile() async {
|
||||
} on FileSystemException catch (e) {
|
||||
Expect.isTrue(
|
||||
e.message.contains('Rename failed'), 'Unexpected error: $e');
|
||||
if (Platform.isLinux || Platform.isMacOS) {
|
||||
if (Platform.isWindows) {
|
||||
Expect.isTrue(e.osError!.message.contains('cannot find the file'),
|
||||
'Unexpected error: $e');
|
||||
} else if (Platform.isLinux || Platform.isMacOS) {
|
||||
Expect.isTrue(e.osError!.message.contains('Not a directory'),
|
||||
'Unexpected error: $e');
|
||||
}
|
||||
|
||||
@@ -143,7 +143,10 @@ testRenameButActuallyFile() async {
|
||||
} on FileSystemException catch (e) {
|
||||
Expect.isTrue(
|
||||
e.message.contains('Rename failed'), 'Unexpected error: $e');
|
||||
if (Platform.isLinux || Platform.isMacOS) {
|
||||
if (Platform.isWindows) {
|
||||
Expect.isTrue(e.osError.message.contains('cannot find the file'),
|
||||
'Unexpected error: $e');
|
||||
} else if (Platform.isLinux || Platform.isMacOS) {
|
||||
Expect.isTrue(e.osError.message.contains('Not a directory'),
|
||||
'Unexpected error: $e');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user