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

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

Issue 23658048: Revert "dart:io | Change File.fullPath to FileSystemEntity.resolveSymbolicLinks." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months 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
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | sdk/lib/io/link.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 class FileSystemEntityType { 7 class FileSystemEntityType {
8 static const FILE = const FileSystemEntityType._internal(0); 8 static const FILE = const FileSystemEntityType._internal(0);
9 static const DIRECTORY = const FileSystemEntityType._internal(1); 9 static const DIRECTORY = const FileSystemEntityType._internal(1);
10 static const LINK = const FileSystemEntityType._internal(2); 10 static const LINK = const FileSystemEntityType._internal(2);
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 * Synchronously renames this file system entity. Returns a [FileSystemEntity] 214 * Synchronously renames this file system entity. Returns a [FileSystemEntity]
215 * instance for the renamed entity. 215 * instance for the renamed entity.
216 * 216 *
217 * If [newPath] identifies an existing entity of the same type, that entity 217 * If [newPath] identifies an existing entity of the same type, that entity
218 * is replaced. If [newPath] identifies an existing entity of a different 218 * is replaced. If [newPath] identifies an existing entity of a different
219 * type, the operation fails and an exception is thrown. 219 * type, the operation fails and an exception is thrown.
220 */ 220 */
221 FileSystemEntity renameSync(String newPath); 221 FileSystemEntity renameSync(String newPath);
222 222
223 /** 223 /**
224 * Resolves the path of a file system object relative to the
225 * current working directory, resolving all symbolic links on
226 * the path and resolving all '..' and '.' path segments.
227 * [resolveSymbolicLinks] returns a [:Future<String>:]
228 *
229 * [resolveSymbolicLinks] uses the operating system's native filesystem api
230 * to resolve the path, using the realpath function on linux and
231 * Mac OS, and the GetFinalPathNameByHandle function on Windows.
232 * If the path does not point to an existing file system object,
233 * [resolveSymbolicLinks] completes the returned Future with an FileException.
234 *
235 * On Windows, symbolic links are resolved to their target before applying
236 * a '..' that follows, and on other platforms, the '..' is applied to the
237 * symbolic link without resolving it. The second behavior can be emulated
238 * on Windows by processing any '..' segments before calling
239 * [resolveSymbolicLinks]. One way of doing this is with the URI class:
240 * [:new Uri.parse('.').resolveUri(new Uri.file(input)).toFilePath();],
241 * since [resolve] removes '..' segments.
242 */
243 Future<String> resolveSymbolicLinks() {
244 // Get a new file service port for each request. We could also cache one.
245 var service = _FileUtils._newServicePort();
246 List request = new List(2);
247 request[0] = _RESOLVE_SYMBOLIC_LINKS_REQUEST;
248 request[1] = path;
249 return service.call(request).then((response) {
250 if (_isErrorResponse(response)) {
251 throw _exceptionFromResponse(response,
252 "Cannot resolve symbolic links",
253 path);
254 }
255 return response;
256 });
257 }
258
259 /**
260 * Resolves the path of a file system object relative to the
261 * current working directory, resolving all symbolic links on
262 * the path and resolving all '..' and '.' path segments.
263 *
264 * [resolveSymbolicLinksSync] uses the operating system's native
265 * filesystem api to resolve the path, using the realpath function
266 * on linux and Mac OS, and the GetFinalPathNameByHandle function on Windows.
267 * If the path does not point to an existing file system object,
268 * [resolveSymbolicLinksSync] throws a FileException.
269 *
270 * On Windows, symbolic links are resolved to their target before applying
271 * a '..' that follows, and on other platforms, the '..' is applied to the
272 * symbolic link without resolving it. The second behavior can be emulated
273 * on Windows by processing any '..' segments before calling
274 * [resolveSymbolicLinks]. One way of doing this is with the URI class:
275 * [:new Uri.parse('.').resolveUri(new Uri.file(input)).toFilePath();],
276 * since [resolve] removes '..' segments.
277 */
278 String resolveSymbolicLinksSync() {
279 var result = _resolveSymbolicLinks(path);
280 _throwIfError(result, "Cannot resolve symbolic links", path);
281 return result;
282 }
283
284
285 /**
286 * Calls the operating system's stat() function on the [path] of this 224 * Calls the operating system's stat() function on the [path] of this
287 * [FileSystemEntity]. Identical to [:FileStat.stat(this.path):]. 225 * [FileSystemEntity]. Identical to [:FileStat.stat(this.path):].
288 * 226 *
289 * Returns a [:Future<FileStat>:] object containing the data returned by 227 * Returns a [:Future<FileStat>:] object containing the data returned by
290 * stat(). 228 * stat().
291 * 229 *
292 * If the call fails, completes the future with a [FileStat] object 230 * If the call fails, completes the future with a [FileStat] object
293 * with .type set to 231 * with .type set to
294 * FileSystemEntityType.NOT_FOUND and the other fields invalid. 232 * FileSystemEntityType.NOT_FOUND and the other fields invalid.
295 */ 233 */
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 Stream<FileSystemEvent> watch({int events: FileSystemEvent.ALL, 309 Stream<FileSystemEvent> watch({int events: FileSystemEvent.ALL,
372 bool recursive: false}) 310 bool recursive: false})
373 => new _FileSystemWatcher(_trimTrailingPathSeparators(path), 311 => new _FileSystemWatcher(_trimTrailingPathSeparators(path),
374 events, 312 events,
375 recursive).stream; 313 recursive).stream;
376 314
377 Future<FileSystemEntity> _delete({recursive: false}); 315 Future<FileSystemEntity> _delete({recursive: false});
378 void _deleteSync({recursive: false}); 316 void _deleteSync({recursive: false});
379 317
380 /** 318 /**
381 * Checks whether two paths refer to the same object in the 319 * Synchronously checks whether two paths refer to the same object in the
382 * file system. Returns a [:Future<bool>:] that completes with the result. 320 * file system. Returns a [:Future<bool>:] that completes with the result.
383 * 321 *
384 * Comparing a link to its target returns false, as does comparing two links 322 * Comparing a link to its target returns false, as does comparing two links
385 * that point to the same target. To check the target of a link, use 323 * that point to the same target. To check the target of a link, use
386 * Link.target explicitly to fetch it. Directory links appearing 324 * Link.target explicitly to fetch it. Directory links appearing
387 * inside a path are followed, though, to find the file system object. 325 * inside a path are followed, though, to find the file system object.
388 * 326 *
389 * Completes the returned Future with an error if one of the paths points 327 * Completes the returned Future with an error if one of the paths points
390 * to an object that does not exist. 328 * to an object that does not exist.
391 */ 329 */
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 474
537 /** 475 /**
538 * Synchronously checks if typeSync(path) returns 476 * Synchronously checks if typeSync(path) returns
539 * FileSystemEntityType.DIRECTORY. 477 * FileSystemEntityType.DIRECTORY.
540 */ 478 */
541 static bool isDirectorySync(String path) => 479 static bool isDirectorySync(String path) =>
542 (_getTypeSync(path, true) == FileSystemEntityType.DIRECTORY._type); 480 (_getTypeSync(path, true) == FileSystemEntityType.DIRECTORY._type);
543 481
544 external static _getType(String path, bool followLinks); 482 external static _getType(String path, bool followLinks);
545 external static _identical(String path1, String path2); 483 external static _identical(String path1, String path2);
546 external static _resolveSymbolicLinks(String path);
547 484
548 static int _getTypeSync(String path, bool followLinks) { 485 static int _getTypeSync(String path, bool followLinks) {
549 var result = _getType(path, followLinks); 486 var result = _getType(path, followLinks);
550 _throwIfError(result, 'Error getting type of FileSystemEntity'); 487 _throwIfError(result, 'Error getting type of FileSystemEntity');
551 return result; 488 return result;
552 } 489 }
553 490
554 static Future<int> _getTypeAsync(String path, bool followLinks) { 491 static Future<int> _getTypeAsync(String path, bool followLinks) {
555 // Get a new file service port for each request. We could also cache one. 492 // Get a new file service port for each request. We could also cache one.
556 var service = _FileUtils._newServicePort(); 493 var service = _FileUtils._newServicePort();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 } 619 }
683 } 620 }
684 621
685 622
686 abstract class _FileSystemWatcher { 623 abstract class _FileSystemWatcher {
687 external factory _FileSystemWatcher(String path, int events, bool recursive); 624 external factory _FileSystemWatcher(String path, int events, bool recursive);
688 external static bool get isSupported; 625 external static bool get isSupported;
689 626
690 Stream<FileSystemEvent> get stream; 627 Stream<FileSystemEvent> get stream;
691 } 628 }
OLDNEW
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | sdk/lib/io/link.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698