| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 bool existsSync() => FileSystemEntity.isLinkSync(path); | 157 bool existsSync() => FileSystemEntity.isLinkSync(path); |
| 158 | 158 |
| 159 Link get absolute => new Link(_absolutePath); | 159 Link get absolute => new Link(_absolutePath); |
| 160 | 160 |
| 161 Future<FileStat> stat() => FileStat.stat(path); | 161 Future<FileStat> stat() => FileStat.stat(path); |
| 162 | 162 |
| 163 FileStat statSync() => FileStat.statSync(path); | 163 FileStat statSync() => FileStat.statSync(path); |
| 164 | 164 |
| 165 Future<Link> create(String target, {bool recursive: false}) { | 165 Future<Link> create(String target, {bool recursive: false}) { |
| 166 if (Platform.operatingSystem == 'windows') { | 166 if (Platform.isWindows) { |
| 167 target = _makeWindowsLinkTarget(target); | 167 target = _makeWindowsLinkTarget(target); |
| 168 } | 168 } |
| 169 var result = recursive ? parent.create(recursive: true) | 169 var result = recursive ? parent.create(recursive: true) |
| 170 : new Future.value(null); | 170 : new Future.value(null); |
| 171 return result | 171 return result |
| 172 .then((_) => _IOService.dispatch(_FILE_CREATE_LINK, [path, target])) | 172 .then((_) => _IOService.dispatch(_FILE_CREATE_LINK, [path, target])) |
| 173 .then((response) { | 173 .then((response) { |
| 174 if (_isErrorResponse(response)) { | 174 if (_isErrorResponse(response)) { |
| 175 throw _exceptionFromResponse( | 175 throw _exceptionFromResponse( |
| 176 response, "Cannot create link to target '$target'", path); | 176 response, "Cannot create link to target '$target'", path); |
| 177 } | 177 } |
| 178 return this; | 178 return this; |
| 179 }); | 179 }); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void createSync(String target, {bool recursive: false}) { | 182 void createSync(String target, {bool recursive: false}) { |
| 183 if (recursive) { | 183 if (recursive) { |
| 184 parent.createSync(recursive: true); | 184 parent.createSync(recursive: true); |
| 185 } | 185 } |
| 186 if (Platform.operatingSystem == 'windows') { | 186 if (Platform.isWindows) { |
| 187 target = _makeWindowsLinkTarget(target); | 187 target = _makeWindowsLinkTarget(target); |
| 188 } | 188 } |
| 189 var result = _File._createLink(path, target); | 189 var result = _File._createLink(path, target); |
| 190 throwIfError(result, "Cannot create link", path); | 190 throwIfError(result, "Cannot create link", path); |
| 191 } | 191 } |
| 192 | 192 |
| 193 // Put target into the form "\??\C:\my\target\dir". | 193 // Put target into the form "\??\C:\my\target\dir". |
| 194 String _makeWindowsLinkTarget(String target) { | 194 String _makeWindowsLinkTarget(String target) { |
| 195 Uri base = new Uri.file('${Directory.current.path}\\'); | 195 Uri base = new Uri.file('${Directory.current.path}\\'); |
| 196 Uri link = new Uri.file(path); | 196 Uri link = new Uri.file(path); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 return new ArgumentError(); | 292 return new ArgumentError(); |
| 293 case _OSERROR_RESPONSE: | 293 case _OSERROR_RESPONSE: |
| 294 var err = new OSError(response[_OSERROR_RESPONSE_MESSAGE], | 294 var err = new OSError(response[_OSERROR_RESPONSE_MESSAGE], |
| 295 response[_OSERROR_RESPONSE_ERROR_CODE]); | 295 response[_OSERROR_RESPONSE_ERROR_CODE]); |
| 296 return new FileSystemException(message, path, err); | 296 return new FileSystemException(message, path, err); |
| 297 default: | 297 default: |
| 298 return new Exception("Unknown error"); | 298 return new Exception("Unknown error"); |
| 299 } | 299 } |
| 300 } | 300 } |
| 301 } | 301 } |
| OLD | NEW |