| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
| 6 import "dart:io"; | 6 import "dart:io"; |
| 7 import "dart:isolate"; | 7 import "dart:isolate"; |
| 8 | 8 |
| 9 testJunctionTypeDelete() { | 9 testJunctionTypeDelete() { |
| 10 var temp = | 10 var temp = |
| 11 Directory.systemTemp.createTempSync('dart_windows_file_system_links'); | 11 Directory.systemTemp.createTempSync('dart_windows_file_system_links'); |
| 12 var x = '${temp.path}${Platform.pathSeparator}x'; | 12 var x = '${temp.path}${Platform.pathSeparator}x'; |
| 13 var y = '${temp.path}${Platform.pathSeparator}y'; | 13 var y = '${temp.path}${Platform.pathSeparator}y'; |
| 14 | 14 |
| 15 new Directory(x).createSync(); | 15 new Directory(x).createSync(); |
| 16 new Link(y).create(x).then((_) { | 16 new Link(y).create(x).then((_) { |
| 17 Expect.isTrue(new Directory(y).existsSync()); | 17 Expect.isTrue(new Directory(y).existsSync()); |
| 18 Expect.isTrue(new Directory(x).existsSync()); | 18 Expect.isTrue(new Directory(x).existsSync()); |
| 19 Expect.isTrue(FileSystemEntity.isLinkSync(y)); | 19 Expect.isTrue(FileSystemEntity.isLinkSync(y)); |
| 20 Expect.isFalse(FileSystemEntity.isLinkSync(x)); | 20 Expect.isFalse(FileSystemEntity.isLinkSync(x)); |
| 21 Expect.isTrue(FileSystemEntity.isDirectorySync(y)); | 21 Expect.isTrue(FileSystemEntity.isDirectorySync(y)); |
| 22 Expect.isTrue(FileSystemEntity.isDirectorySync(x)); | 22 Expect.isTrue(FileSystemEntity.isDirectorySync(x)); |
| 23 Expect.equals(FileSystemEntityType.DIRECTORY, FileSystemEntity.typeSync(y)); |
| 24 Expect.equals(FileSystemEntityType.DIRECTORY, FileSystemEntity.typeSync(x)); |
| 25 Expect.equals(FileSystemEntityType.LINK, |
| 26 FileSystemEntity.typeSync(y, followLinks: false)); |
| 23 Expect.equals(FileSystemEntityType.DIRECTORY, | 27 Expect.equals(FileSystemEntityType.DIRECTORY, |
| 24 FileSystemEntity.typeSync(y)); | 28 FileSystemEntity.typeSync(x, followLinks: false)); |
| 25 Expect.equals(FileSystemEntityType.DIRECTORY, | |
| 26 FileSystemEntity.typeSync(x)); | |
| 27 Expect.equals(FileSystemEntityType.LINK, | |
| 28 FileSystemEntity.typeSync(y, followLinks: false)); | |
| 29 Expect.equals(FileSystemEntityType.DIRECTORY, | |
| 30 FileSystemEntity.typeSync(x, followLinks: false)); | |
| 31 Expect.equals(x, new Link(y).targetSync()); | 29 Expect.equals(x, new Link(y).targetSync()); |
| 32 | 30 |
| 33 // Test Junction pointing to a missing directory. | 31 // Test Junction pointing to a missing directory. |
| 34 new Directory(x).deleteSync(); | 32 new Directory(x).deleteSync(); |
| 35 Expect.isTrue(new Link(y).existsSync()); | 33 Expect.isTrue(new Link(y).existsSync()); |
| 36 Expect.isFalse(new Directory(x).existsSync()); | 34 Expect.isFalse(new Directory(x).existsSync()); |
| 37 Expect.isTrue(FileSystemEntity.isLinkSync(y)); | 35 Expect.isTrue(FileSystemEntity.isLinkSync(y)); |
| 38 Expect.isFalse(FileSystemEntity.isLinkSync(x)); | 36 Expect.isFalse(FileSystemEntity.isLinkSync(x)); |
| 39 Expect.isFalse(FileSystemEntity.isDirectorySync(y)); | 37 Expect.isFalse(FileSystemEntity.isDirectorySync(y)); |
| 40 Expect.isFalse(FileSystemEntity.isDirectorySync(x)); | 38 Expect.isFalse(FileSystemEntity.isDirectorySync(x)); |
| 39 Expect.equals(FileSystemEntityType.LINK, FileSystemEntity.typeSync(y)); |
| 40 Expect.equals(FileSystemEntityType.NOT_FOUND, FileSystemEntity.typeSync(x)); |
| 41 Expect.equals(FileSystemEntityType.LINK, | 41 Expect.equals(FileSystemEntityType.LINK, |
| 42 FileSystemEntity.typeSync(y)); | 42 FileSystemEntity.typeSync(y, followLinks: false)); |
| 43 Expect.equals(FileSystemEntityType.NOT_FOUND, | 43 Expect.equals(FileSystemEntityType.NOT_FOUND, |
| 44 FileSystemEntity.typeSync(x)); | 44 FileSystemEntity.typeSync(x, followLinks: false)); |
| 45 Expect.equals(FileSystemEntityType.LINK, | |
| 46 FileSystemEntity.typeSync(y, followLinks: false)); | |
| 47 Expect.equals(FileSystemEntityType.NOT_FOUND, | |
| 48 FileSystemEntity.typeSync(x, followLinks: false)); | |
| 49 Expect.equals(x, new Link(y).targetSync()); | 45 Expect.equals(x, new Link(y).targetSync()); |
| 50 | 46 |
| 51 // Delete Junction pointing to a missing directory. | 47 // Delete Junction pointing to a missing directory. |
| 52 new Link(y).deleteSync(); | 48 new Link(y).deleteSync(); |
| 53 Expect.isFalse(FileSystemEntity.isLinkSync(y)); | 49 Expect.isFalse(FileSystemEntity.isLinkSync(y)); |
| 54 Expect.equals(FileSystemEntityType.NOT_FOUND, | 50 Expect.equals(FileSystemEntityType.NOT_FOUND, FileSystemEntity.typeSync(y)); |
| 55 FileSystemEntity.typeSync(y)); | |
| 56 Expect.throws(() => new Link(y).targetSync()); | 51 Expect.throws(() => new Link(y).targetSync()); |
| 57 | 52 |
| 58 new Directory(x).createSync(); | 53 new Directory(x).createSync(); |
| 59 new Link(y).create(x).then((_) { | 54 new Link(y).create(x).then((_) { |
| 60 Expect.equals(FileSystemEntityType.LINK, | 55 Expect.equals(FileSystemEntityType.LINK, |
| 61 FileSystemEntity.typeSync(y, followLinks: false)); | 56 FileSystemEntity.typeSync(y, followLinks: false)); |
| 62 Expect.equals(FileSystemEntityType.DIRECTORY, | 57 Expect.equals(FileSystemEntityType.DIRECTORY, |
| 63 FileSystemEntity.typeSync(x, followLinks: false)); | 58 FileSystemEntity.typeSync(x, followLinks: false)); |
| 64 Expect.equals(x, new Link(y).targetSync()); | 59 Expect.equals(x, new Link(y).targetSync()); |
| 65 | 60 |
| 66 // Delete Junction pointing to an existing directory. | 61 // Delete Junction pointing to an existing directory. |
| 67 new Directory(y).deleteSync(); | 62 new Directory(y).deleteSync(); |
| 63 Expect.equals( |
| 64 FileSystemEntityType.NOT_FOUND, FileSystemEntity.typeSync(y)); |
| 68 Expect.equals(FileSystemEntityType.NOT_FOUND, | 65 Expect.equals(FileSystemEntityType.NOT_FOUND, |
| 69 FileSystemEntity.typeSync(y)); | 66 FileSystemEntity.typeSync(y, followLinks: false)); |
| 70 Expect.equals(FileSystemEntityType.NOT_FOUND, | 67 Expect.equals( |
| 71 FileSystemEntity.typeSync(y, followLinks: false)); | 68 FileSystemEntityType.DIRECTORY, FileSystemEntity.typeSync(x)); |
| 72 Expect.equals(FileSystemEntityType.DIRECTORY, | 69 Expect.equals(FileSystemEntityType.DIRECTORY, |
| 73 FileSystemEntity.typeSync(x)); | 70 FileSystemEntity.typeSync(x, followLinks: false)); |
| 74 Expect.equals(FileSystemEntityType.DIRECTORY, | |
| 75 FileSystemEntity.typeSync(x, followLinks: false)); | |
| 76 Expect.throws(() => new Link(y).targetSync()); | 71 Expect.throws(() => new Link(y).targetSync()); |
| 77 | 72 |
| 78 temp.deleteSync(recursive: true); | 73 temp.deleteSync(recursive: true); |
| 79 }); | 74 }); |
| 80 }); | 75 }); |
| 81 } | 76 } |
| 82 | 77 |
| 83 | |
| 84 main() { | 78 main() { |
| 85 // Links on other platforms are tested by file_system_[async_]links_test. | 79 // Links on other platforms are tested by file_system_[async_]links_test. |
| 86 if (Platform.operatingSystem == 'windows') { | 80 if (Platform.operatingSystem == 'windows') { |
| 87 testJunctionTypeDelete(); | 81 testJunctionTypeDelete(); |
| 88 } | 82 } |
| 89 } | 83 } |
| OLD | NEW |