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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 // the old name atomically. | 216 // the old name atomically. |
217 deleteSync(); | 217 deleteSync(); |
218 createSync(target); | 218 createSync(target); |
219 } | 219 } |
220 | 220 |
221 Future<Link> update(String target) { | 221 Future<Link> update(String target) { |
222 // TODO(12414): Replace with atomic update, where supported by platform. | 222 // TODO(12414): Replace with atomic update, where supported by platform. |
223 // Atomically changing a link can be done by creating the new link, with | 223 // Atomically changing a link can be done by creating the new link, with |
224 // a different name, and using the rename() posix call to move it to | 224 // a different name, and using the rename() posix call to move it to |
225 // the old name atomically. | 225 // the old name atomically. |
226 return delete().then/*<Link>*/((_) => create(target)); | 226 return delete().then<Link>((_) => create(target)); |
227 } | 227 } |
228 | 228 |
229 Future<Link> _delete({bool recursive: false}) { | 229 Future<Link> _delete({bool recursive: false}) { |
230 if (recursive) { | 230 if (recursive) { |
231 return new Directory(path).delete(recursive: true).then((_) => this); | 231 return new Directory(path).delete(recursive: true).then((_) => this); |
232 } | 232 } |
233 return _IOService._dispatch(_FILE_DELETE_LINK, [path]).then((response) { | 233 return _IOService._dispatch(_FILE_DELETE_LINK, [path]).then((response) { |
234 if (_isErrorResponse(response)) { | 234 if (_isErrorResponse(response)) { |
235 throw _exceptionFromResponse(response, "Cannot delete link", path); | 235 throw _exceptionFromResponse(response, "Cannot delete link", path); |
236 } | 236 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 return new ArgumentError(); | 296 return new ArgumentError(); |
297 case _OSERROR_RESPONSE: | 297 case _OSERROR_RESPONSE: |
298 var err = new OSError(response[_OSERROR_RESPONSE_MESSAGE], | 298 var err = new OSError(response[_OSERROR_RESPONSE_MESSAGE], |
299 response[_OSERROR_RESPONSE_ERROR_CODE]); | 299 response[_OSERROR_RESPONSE_ERROR_CODE]); |
300 return new FileSystemException(message, path, err); | 300 return new FileSystemException(message, path, err); |
301 default: | 301 default: |
302 return new Exception("Unknown error"); | 302 return new Exception("Unknown error"); |
303 } | 303 } |
304 } | 304 } |
305 } | 305 } |
OLD | NEW |