| 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 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * [Link] objects are references to filesystem links. | 8 * [Link] objects are references to filesystem links. |
| 9 * | 9 * |
| 10 */ | 10 */ |
| 11 abstract class Link implements FileSystemEntity { | 11 abstract class Link implements FileSystemEntity { |
| 12 /** | 12 /** |
| 13 * Creates a Link object. | 13 * Creates a Link object. |
| 14 */ | 14 */ |
| 15 factory Link(String path) => new _Link(path); | 15 factory Link(String path) => new _Link(path); |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * Create a Lint object from a URI. |
| 19 * |
| 20 * If [uri] cannot reference a link this throws [UnsupportedError]. |
| 21 */ |
| 22 factory Link.fromUri(Uri uri) => new Link(uri.toFilePath()); |
| 23 |
| 24 /** |
| 18 * Creates a symbolic link. Returns a [:Future<Link>:] that completes with | 25 * Creates a symbolic link. Returns a [:Future<Link>:] that completes with |
| 19 * the link when it has been created. If the link exists, | 26 * the link when it has been created. If the link exists, |
| 20 * the future will complete with an error. | 27 * the future will complete with an error. |
| 21 * | 28 * |
| 22 * If [recursive] is false, the default, the link is created | 29 * If [recursive] is false, the default, the link is created |
| 23 * only if all directories in its path exist. | 30 * only if all directories in its path exist. |
| 24 * If [recursive] is true, all non-existing path | 31 * If [recursive] is true, all non-existing path |
| 25 * components are created. The directories in the path of [target] are | 32 * components are created. The directories in the path of [target] are |
| 26 * not affected, unless they are also in [path]. | 33 * not affected, unless they are also in [path]. |
| 27 * | 34 * |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 class _Link extends FileSystemEntity implements Link { | 143 class _Link extends FileSystemEntity implements Link { |
| 137 final String path; | 144 final String path; |
| 138 | 145 |
| 139 _Link(String this.path) { | 146 _Link(String this.path) { |
| 140 if (path is! String) { | 147 if (path is! String) { |
| 141 throw new ArgumentError('${Error.safeToString(path)} ' | 148 throw new ArgumentError('${Error.safeToString(path)} ' |
| 142 'is not a String'); | 149 'is not a String'); |
| 143 } | 150 } |
| 144 } | 151 } |
| 145 | 152 |
| 146 | |
| 147 String toString() => "Link: '$path'"; | 153 String toString() => "Link: '$path'"; |
| 148 | 154 |
| 149 Future<bool> exists() => FileSystemEntity.isLink(path); | 155 Future<bool> exists() => FileSystemEntity.isLink(path); |
| 150 | 156 |
| 151 bool existsSync() => FileSystemEntity.isLinkSync(path); | 157 bool existsSync() => FileSystemEntity.isLinkSync(path); |
| 152 | 158 |
| 153 Link get absolute => new Link(_absolutePath); | 159 Link get absolute => new Link(_absolutePath); |
| 154 | 160 |
| 155 Future<FileStat> stat() => FileStat.stat(path); | 161 Future<FileStat> stat() => FileStat.stat(path); |
| 156 | 162 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 return new ArgumentError(); | 291 return new ArgumentError(); |
| 286 case _OSERROR_RESPONSE: | 292 case _OSERROR_RESPONSE: |
| 287 var err = new OSError(response[_OSERROR_RESPONSE_MESSAGE], | 293 var err = new OSError(response[_OSERROR_RESPONSE_MESSAGE], |
| 288 response[_OSERROR_RESPONSE_ERROR_CODE]); | 294 response[_OSERROR_RESPONSE_ERROR_CODE]); |
| 289 return new FileSystemException(message, path, err); | 295 return new FileSystemException(message, path, err); |
| 290 default: | 296 default: |
| 291 return new Exception("Unknown error"); | 297 return new Exception("Unknown error"); |
| 292 } | 298 } |
| 293 } | 299 } |
| 294 } | 300 } |
| OLD | NEW |