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 */ |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 /** | 57 /** |
58 * Updates the link. Returns a [:Future<Link>:] that completes with the | 58 * Updates the link. Returns a [:Future<Link>:] that completes with the |
59 * link when it has been updated. Calling [update] on a non-existing link | 59 * link when it has been updated. Calling [update] on a non-existing link |
60 * will complete its returned future with an exception. | 60 * will complete its returned future with an exception. |
61 * | 61 * |
62 * On the Windows platform, this will only work with directories, and the | 62 * On the Windows platform, this will only work with directories, and the |
63 * target directory must exist. | 63 * target directory must exist. |
64 */ | 64 */ |
65 Future<Link> update(String target); | 65 Future<Link> update(String target); |
66 | 66 |
| 67 Future<String> resolveSymbolicLinks(); |
| 68 |
| 69 String resolveSymbolicLinksSync(); |
| 70 |
67 /** | 71 /** |
68 * Renames this link. Returns a `Future<Link>` that completes | 72 * Renames this link. Returns a `Future<Link>` that completes |
69 * with a [Link] instance for the renamed link. | 73 * with a [Link] instance for the renamed link. |
70 * | 74 * |
71 * If [newPath] identifies an existing link, that link is | 75 * If [newPath] identifies an existing link, that link is |
72 * replaced. If [newPath] identifies an existing file or directory, | 76 * replaced. If [newPath] identifies an existing file or directory, |
73 * the operation fails and the future completes with an exception. | 77 * the operation fails and the future completes with an exception. |
74 */ | 78 */ |
75 Future<Link> rename(String newPath); | 79 Future<Link> rename(String newPath); |
76 | 80 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 } | 217 } |
214 | 218 |
215 void _deleteSync({bool recursive: false}) { | 219 void _deleteSync({bool recursive: false}) { |
216 if (recursive) { | 220 if (recursive) { |
217 return new Directory(path).deleteSync(recursive: true); | 221 return new Directory(path).deleteSync(recursive: true); |
218 } | 222 } |
219 var result = _File._deleteLinkNative(path); | 223 var result = _File._deleteLinkNative(path); |
220 throwIfError(result, "Cannot delete link", path); | 224 throwIfError(result, "Cannot delete link", path); |
221 } | 225 } |
222 | 226 |
| 227 Future<String> resolveSymbolicLinks() { |
| 228 _ensureFileService(); |
| 229 List request = new List(2); |
| 230 request[0] = _RESOLVE_SYMBOLIC_LINKS_REQUEST; |
| 231 request[1] = path; |
| 232 return _fileService.call(request).then((response) { |
| 233 if (_isErrorResponse(response)) { |
| 234 throw _exceptionFromResponse( |
| 235 response, "Cannot resolve symbolic links", path); |
| 236 } |
| 237 return response; |
| 238 }); |
| 239 } |
| 240 |
| 241 String resolveSymbolicLinksSync() { |
| 242 var result = _File._resolveSymbolicLinks(path); |
| 243 if (result is OSError) { |
| 244 throw new LinkException( |
| 245 "Cannot resolve symbolic links", path, result); |
| 246 } |
| 247 return result; |
| 248 } |
| 249 |
223 Future<Link> rename(String newPath) { | 250 Future<Link> rename(String newPath) { |
224 _ensureFileService(); | 251 _ensureFileService(); |
225 List request = new List(3); | 252 List request = new List(3); |
226 request[0] = _RENAME_LINK_REQUEST; | 253 request[0] = _RENAME_LINK_REQUEST; |
227 request[1] = path; | 254 request[1] = path; |
228 request[2] = newPath; | 255 request[2] = newPath; |
229 return _fileService.call(request).then((response) { | 256 return _fileService.call(request).then((response) { |
230 if (_isErrorResponse(response)) { | 257 if (_isErrorResponse(response)) { |
231 throw _exceptionFromResponse( | 258 throw _exceptionFromResponse( |
232 response, "Cannot rename link to '$newPath'", path); | 259 response, "Cannot rename link to '$newPath'", path); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 if (path != null) { | 340 if (path != null) { |
314 sb.write(", path = $path"); | 341 sb.write(", path = $path"); |
315 } | 342 } |
316 } | 343 } |
317 return sb.toString(); | 344 return sb.toString(); |
318 } | 345 } |
319 final String message; | 346 final String message; |
320 final String path; | 347 final String path; |
321 final OSError osError; | 348 final OSError osError; |
322 } | 349 } |
OLD | NEW |