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

Unified Diff: sdk/lib/io/file_system_entity.dart

Issue 156633002: Change FileStat static methods to return NOT_FOUND instead for throwing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/standalone/io/file_stat_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/file_system_entity.dart
diff --git a/sdk/lib/io/file_system_entity.dart b/sdk/lib/io/file_system_entity.dart
index 1912d61309d4a13c752300b712c313f2ca26d0e6..23b4f34b5af842cbe74980727cf7ace647487852 100644
--- a/sdk/lib/io/file_system_entity.dart
+++ b/sdk/lib/io/file_system_entity.dart
@@ -35,6 +35,8 @@ class FileStat {
static const _MODE = 4;
static const _SIZE = 5;
+ static const _notFound = const FileStat._internalNotFound();
+
/**
* The time of the last change to the data or metadata of the file system
* object. On Windows platforms, this is instead the file creation time.
@@ -73,6 +75,10 @@ class FileStat {
this.mode,
this.size);
+ const FileStat._internalNotFound() :
+ changed = null, modified = null, accessed = null,
+ type = FileSystemEntityType.NOT_FOUND, mode = 0, size = -1;
+
external static List<int> _statSync(String path);
@@ -88,7 +94,7 @@ class FileStat {
path = FileSystemEntity._trimTrailingPathSeparators(path);
}
var data = _statSync(path);
- if (data is OSError) throw data;
+ if (data is OSError) return FileStat._notFound;
return new FileStat._internal(
new DateTime.fromMillisecondsSinceEpoch(data[_CHANGED_TIME] * 1000),
new DateTime.fromMillisecondsSinceEpoch(data[_MODIFIED_TIME] * 1000),
@@ -112,9 +118,7 @@ class FileStat {
}
return _IOService.dispatch(_FILE_STAT, [path]).then((response) {
if (_isErrorResponse(response)) {
- throw _exceptionFromResponse(response,
- "Error getting stat",
- path);
+ return FileStat._notFound;
}
// Unwrap the real list from the "I'm not an error" wrapper.
List data = response[1];
« no previous file with comments | « no previous file | tests/standalone/io/file_stat_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698