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

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

Issue 2681683005: [dart:io] Adds functions to set file access and modification time (Closed)
Patch Set: Update changelog Created 3 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 | « sdk/lib/io/file.dart ('k') | sdk/lib/io/file_system_entity.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/file_impl.dart
diff --git a/sdk/lib/io/file_impl.dart b/sdk/lib/io/file_impl.dart
index dce4cbc742bfb130997f34f28b209e492ede8684..0e879b12976e7343beb601e1db256c87955e5bd9 100644
--- a/sdk/lib/io/file_impl.dart
+++ b/sdk/lib/io/file_impl.dart
@@ -248,10 +248,6 @@ class _File extends FileSystemEntity implements File {
File get absolute => new File(_absolutePath);
- Future<FileStat> stat() => FileStat.stat(path);
-
- FileStat statSync() => FileStat.statSync(path);
-
Future<File> create({bool recursive: false}) {
var result = recursive ? parent.create(recursive: true)
: new Future.value(null);
@@ -380,6 +376,49 @@ class _File extends FileSystemEntity implements File {
return result;
}
+ Future<DateTime> lastAccessed() {
+ return _IOService._dispatch(_FILE_LAST_ACCESSED, [path]).then((response) {
+ if (_isErrorResponse(response)) {
+ throw _exceptionFromResponse(response,
+ "Cannot retrieve access time",
+ path);
+ }
+ return new DateTime.fromMillisecondsSinceEpoch(response);
+ });
+ }
+
+ external static _lastAccessed(String path);
+
+ DateTime lastAccessedSync() {
+ var ms = _lastAccessed(path);
+ throwIfError(ms, "Cannot retrieve access time", path);
+ return new DateTime.fromMillisecondsSinceEpoch(ms);
+ }
+
+ Future setLastAccessed(DateTime time) {
+ int millis = time.millisecondsSinceEpoch;
+ return _IOService._dispatch(_FILE_SET_LAST_ACCESSED, [path, millis])
+ .then((response) {
+ if (_isErrorResponse(response)) {
+ throw _exceptionFromResponse(response,
+ "Cannot set access time",
+ path);
+ }
+ return null;
+ });
+ }
+
+ external static _setLastAccessed(String path, int millis);
+
+ void setLastAccessedSync(DateTime time) {
+ int millis = time.millisecondsSinceEpoch;
+ var result = _setLastAccessed(path, millis);
+ if (result is OSError) {
+ throw new FileSystemException("Failed to set file access time",
+ path, result);
+ }
+ }
+
Future<DateTime> lastModified() {
return _IOService._dispatch(_FILE_LAST_MODIFIED, [path]).then((response) {
if (_isErrorResponse(response)) {
@@ -399,6 +438,30 @@ class _File extends FileSystemEntity implements File {
return new DateTime.fromMillisecondsSinceEpoch(ms);
}
+ Future setLastModified(DateTime time) {
+ int millis = time.millisecondsSinceEpoch;
+ return _IOService._dispatch(_FILE_SET_LAST_MODIFIED, [path, millis])
+ .then((response) {
+ if (_isErrorResponse(response)) {
+ throw _exceptionFromResponse(response,
+ "Cannot set modification time",
+ path);
+ }
+ return null;
+ });
+ }
+
+ external static _setLastModified(String path, int millis);
+
+ void setLastModifiedSync(DateTime time) {
+ int millis = time.millisecondsSinceEpoch;
+ var result = _setLastModified(path, millis);
+ if (result is OSError) {
+ throw new FileSystemException("Failed to set file modification time",
+ path, result);
+ }
+ }
+
external static _open(String path, int mode);
RandomAccessFile openSync({FileMode mode: FileMode.READ}) {
« no previous file with comments | « sdk/lib/io/file.dart ('k') | sdk/lib/io/file_system_entity.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698