OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import "dart:io"; |
| 6 import "dart:isolate"; |
| 7 |
| 8 // Test the dart:io Link class. |
| 9 |
| 10 testCreateSync() { |
| 11 Path base = new Path(new Directory('').createTempSync().path); |
| 12 String link = base.append('link').toNativePath(); |
| 13 String target = base.append('target').toNativePath(); |
| 14 new Directory(target).createSync(); |
| 15 new Link(link).createSync(target); |
| 16 |
| 17 Expect.equals(FileSystemEntityType.DIRECTORY, |
| 18 FileSystemEntity.typeSync(link)); |
| 19 Expect.equals(FileSystemEntityType.DIRECTORY, |
| 20 FileSystemEntity.typeSync(target)); |
| 21 Expect.equals(FileSystemEntityType.LINK, |
| 22 FileSystemEntity.typeSync(link, followLinks: false)); |
| 23 Expect.equals(FileSystemEntityType.DIRECTORY, |
| 24 FileSystemEntity.typeSync(target, followLinks: false)); |
| 25 Expect.isTrue(FileSystemEntity.isLinkSync(link)); |
| 26 Expect.isFalse(FileSystemEntity.isLinkSync(target)); |
| 27 Expect.isTrue(new Directory(link).existsSync()); |
| 28 Expect.isTrue(new Directory(target).existsSync()); |
| 29 Expect.isTrue(new Link(link).existsSync()); |
| 30 Expect.isFalse(new Link(target).existsSync()); |
| 31 |
| 32 String createdThroughLink = |
| 33 base.append('link/createdThroughLink').toNativePath(); |
| 34 String createdDirectly = base.append('target/createdDirectly').toNativePath(); |
| 35 new Directory(createdThroughLink).createSync(); |
| 36 new Directory(createdDirectly).createSync(); |
| 37 Expect.isTrue(new Directory(createdThroughLink).existsSync()); |
| 38 Expect.isTrue(new Directory(createdDirectly).existsSync()); |
| 39 Expect.isTrue(new Directory.fromPath(base.append('link/createdDirectly')) |
| 40 .existsSync()); |
| 41 Expect.isTrue(new Directory.fromPath(base.append('target/createdThroughLink')) |
| 42 .existsSync()); |
| 43 Expect.equals(FileSystemEntityType.DIRECTORY, |
| 44 FileSystemEntity.typeSync(createdThroughLink, |
| 45 followLinks: false)); |
| 46 Expect.equals(FileSystemEntityType.DIRECTORY, |
| 47 FileSystemEntity.typeSync(createdDirectly, followLinks: false)); |
| 48 |
| 49 new Directory.fromPath(base).deleteSync(recursive: true); |
| 50 } |
| 51 |
| 52 |
| 53 main() { |
| 54 testCreateSync(); |
| 55 } |
OLD | NEW |