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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 String toString() => "Link: '$path'"; | 117 String toString() => "Link: '$path'"; |
118 | 118 |
119 Future<bool> exists() { | 119 Future<bool> exists() { |
120 // TODO(whesse): Replace with asynchronous version. | 120 // TODO(whesse): Replace with asynchronous version. |
121 return new Future.immediate(existsSync()); | 121 return new Future.immediate(existsSync()); |
122 } | 122 } |
123 | 123 |
124 bool existsSync() => FileSystemEntity.isLinkSync(path); | 124 bool existsSync() => FileSystemEntity.isLinkSync(path); |
125 | 125 |
126 Future<Link> create(String target) { | 126 Future<Link> create(String target) { |
127 // TODO(whesse): Replace with asynchronous version. | 127 _ensureFileService(); |
128 return new Future.of(() { | 128 List request = new List(3); |
129 createSync(target); | 129 request[0] = _CREATE_LINK_REQUEST; |
| 130 request[1] = path; |
| 131 request[2] = target; |
| 132 return _fileService.call(request).then((response) { |
| 133 if (_isErrorResponse(response)) { |
| 134 throw _exceptionFromResponse(response, |
| 135 "Cannot create link '$path' to target '$target'"); |
| 136 } |
130 return this; | 137 return this; |
131 }); | 138 }); |
132 } | 139 } |
133 | 140 |
134 void createSync(String target) { | 141 void createSync(String target) { |
135 if (Platform.operatingSystem == 'windows') { | 142 if (Platform.operatingSystem == 'windows') { |
136 target = _makeWindowsLinkTarget(target); | 143 target = _makeWindowsLinkTarget(target); |
137 } | 144 } |
138 var result = _File._createLink(path, target); | 145 var result = _File._createLink(path, target); |
139 throwIfError(result, "Cannot create link '$path'"); | 146 throwIfError(result, "Cannot create link '$path'"); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 if (path != null) { | 253 if (path != null) { |
247 sb.write(", path = $path"); | 254 sb.write(", path = $path"); |
248 } | 255 } |
249 } | 256 } |
250 return sb.toString(); | 257 return sb.toString(); |
251 } | 258 } |
252 final String message; | 259 final String message; |
253 final String path; | 260 final String path; |
254 final OSError osError; | 261 final OSError osError; |
255 } | 262 } |
OLD | NEW |