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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 return this; | 197 return this; |
198 }); | 198 }); |
199 } | 199 } |
200 | 200 |
201 void deleteSync() { | 201 void deleteSync() { |
202 var result = _File._deleteLink(path); | 202 var result = _File._deleteLink(path); |
203 throwIfError(result, "Cannot delete link '$path'"); | 203 throwIfError(result, "Cannot delete link '$path'"); |
204 } | 204 } |
205 | 205 |
206 Future<String> target() { | 206 Future<String> target() { |
207 // TODO(whesse): Replace with asynchronous version. | 207 _ensureFileService(); |
208 return new Future.sync(targetSync); | 208 List request = new List(2); |
| 209 request[0] = _LINK_TARGET_REQUEST; |
| 210 request[1] = path; |
| 211 return _fileService.call(request).then((response) { |
| 212 if (_isErrorResponse(response)) { |
| 213 throw _exceptionFromResponse(response, |
| 214 "Cannot get target of link '$path'"); |
| 215 } |
| 216 return response; |
| 217 }); |
209 } | 218 } |
210 | 219 |
211 String targetSync() { | 220 String targetSync() { |
212 var result = _File._linkTarget(path); | 221 var result = _File._linkTarget(path); |
213 throwIfError(result, "Cannot read link '$path'"); | 222 throwIfError(result, "Cannot read link '$path'"); |
214 return result; | 223 return result; |
215 } | 224 } |
216 | 225 |
217 static throwIfError(Object result, String msg) { | 226 static throwIfError(Object result, String msg) { |
218 if (result is OSError) { | 227 if (result is OSError) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 if (path != null) { | 275 if (path != null) { |
267 sb.write(", path = $path"); | 276 sb.write(", path = $path"); |
268 } | 277 } |
269 } | 278 } |
270 return sb.toString(); | 279 return sb.toString(); |
271 } | 280 } |
272 final String message; | 281 final String message; |
273 final String path; | 282 final String path; |
274 final OSError osError; | 283 final OSError osError; |
275 } | 284 } |
OLD | NEW |