Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Side by Side Diff: sdk/lib/io/link.dart

Issue 57943002: Add fromUri constructor to File, Directory and Link (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added tests Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 */
11 abstract class Link implements FileSystemEntity { 11 abstract class Link implements FileSystemEntity {
12 /** 12 /**
13 * Creates a Link object. 13 * Creates a Link object.
14 */ 14 */
15 factory Link(String path) => new _Link(path); 15 factory Link(String path) => new _Link(path);
16 16
17 /** 17 /**
18 * Create a Lint object from a URI.
19 *
20 * If [uri] cannot reference a link this throws [UnsupportedError].
21 */
22 factory Link.fromUri(Uri uri) => new _Link.fromUri(uri);
23 /**
18 * Creates a symbolic link. Returns a [:Future<Link>:] that completes with 24 * Creates a symbolic link. Returns a [:Future<Link>:] that completes with
19 * the link when it has been created. If the link exists, 25 * the link when it has been created. If the link exists,
20 * the future will complete with an error. 26 * the future will complete with an error.
21 * 27 *
22 * If [recursive] is false, the default, the link is created 28 * If [recursive] is false, the default, the link is created
23 * only if all directories in its path exist. 29 * only if all directories in its path exist.
24 * If [recursive] is true, all non-existing path 30 * If [recursive] is true, all non-existing path
25 * components are created. The directories in the path of [target] are 31 * components are created. The directories in the path of [target] are
26 * not affected, unless they are also in [path]. 32 * not affected, unless they are also in [path].
27 * 33 *
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 class _Link extends FileSystemEntity implements Link { 142 class _Link extends FileSystemEntity implements Link {
137 final String path; 143 final String path;
138 144
139 _Link(String this.path) { 145 _Link(String this.path) {
140 if (path is! String) { 146 if (path is! String) {
141 throw new ArgumentError('${Error.safeToString(path)} ' 147 throw new ArgumentError('${Error.safeToString(path)} '
142 'is not a String'); 148 'is not a String');
143 } 149 }
144 } 150 }
145 151
152 factory _Link.fromUri(Uri uri) => new _Link(uri.toFilePath());
146 153
147 String toString() => "Link: '$path'"; 154 String toString() => "Link: '$path'";
148 155
149 Future<bool> exists() => FileSystemEntity.isLink(path); 156 Future<bool> exists() => FileSystemEntity.isLink(path);
150 157
151 bool existsSync() => FileSystemEntity.isLinkSync(path); 158 bool existsSync() => FileSystemEntity.isLinkSync(path);
152 159
153 Link get absolute => new Link(_absolutePath); 160 Link get absolute => new Link(_absolutePath);
154 161
155 Future<FileStat> stat() => FileStat.stat(path); 162 Future<FileStat> stat() => FileStat.stat(path);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 return new ArgumentError(); 292 return new ArgumentError();
286 case _OSERROR_RESPONSE: 293 case _OSERROR_RESPONSE:
287 var err = new OSError(response[_OSERROR_RESPONSE_MESSAGE], 294 var err = new OSError(response[_OSERROR_RESPONSE_MESSAGE],
288 response[_OSERROR_RESPONSE_ERROR_CODE]); 295 response[_OSERROR_RESPONSE_ERROR_CODE]);
289 return new FileSystemException(message, path, err); 296 return new FileSystemException(message, path, err);
290 default: 297 default:
291 return new Exception("Unknown error"); 298 return new Exception("Unknown error");
292 } 299 }
293 } 300 }
294 } 301 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698