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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 SendPort _fileService; | 123 SendPort _fileService; |
124 | 124 |
125 _Link(String this.path); | 125 _Link(String this.path); |
126 | 126 |
127 _Link.fromPath(Path inputPath) : path = inputPath.toNativePath(); | 127 _Link.fromPath(Path inputPath) : path = inputPath.toNativePath(); |
128 | 128 |
129 String toString() => "Link: '$path'"; | 129 String toString() => "Link: '$path'"; |
130 | 130 |
131 Future<bool> exists() { | 131 Future<bool> exists() { |
132 // TODO(whesse): Replace with asynchronous version. | 132 // TODO(whesse): Replace with asynchronous version. |
133 return new Future.immediate(existsSync()); | 133 return new Future.value(existsSync()); |
134 } | 134 } |
135 | 135 |
136 bool existsSync() => FileSystemEntity.isLinkSync(path); | 136 bool existsSync() => FileSystemEntity.isLinkSync(path); |
137 | 137 |
138 Future<Link> create(String target) { | 138 Future<Link> create(String target) { |
139 _ensureFileService(); | 139 _ensureFileService(); |
140 if (Platform.operatingSystem == 'windows') { | 140 if (Platform.operatingSystem == 'windows') { |
141 target = _makeWindowsLinkTarget(target); | 141 target = _makeWindowsLinkTarget(target); |
142 } | 142 } |
143 List request = new List(3); | 143 List request = new List(3); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // TODO(whesse): Replace with asynchronous version. |
208 return new Future.of(targetSync); | 208 return new Future.sync(targetSync); |
209 } | 209 } |
210 | 210 |
211 String targetSync() { | 211 String targetSync() { |
212 var result = _File._linkTarget(path); | 212 var result = _File._linkTarget(path); |
213 throwIfError(result, "Cannot read link '$path'"); | 213 throwIfError(result, "Cannot read link '$path'"); |
214 return result; | 214 return result; |
215 } | 215 } |
216 | 216 |
217 static throwIfError(Object result, String msg) { | 217 static throwIfError(Object result, String msg) { |
218 if (result is OSError) { | 218 if (result is OSError) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 if (path != null) { | 266 if (path != null) { |
267 sb.write(", path = $path"); | 267 sb.write(", path = $path"); |
268 } | 268 } |
269 } | 269 } |
270 return sb.toString(); | 270 return sb.toString(); |
271 } | 271 } |
272 final String message; | 272 final String message; |
273 final String path; | 273 final String path; |
274 final OSError osError; | 274 final OSError osError; |
275 } | 275 } |
OLD | NEW |