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

Unified Diff: runtime/bin/file.cc

Issue 10443008: Implement File.lastModified. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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
Index: runtime/bin/file.cc
diff --git a/runtime/bin/file.cc b/runtime/bin/file.cc
index e9166e5b2b522614140405f9d2da7dc2b1718800..30a42347e42b390cb0a887e17ffa8519dd586787 100644
--- a/runtime/bin/file.cc
+++ b/runtime/bin/file.cc
@@ -357,6 +357,22 @@ void FUNCTION_NAME(File_LengthFromName)(Dart_NativeArguments args) {
}
+void FUNCTION_NAME(File_LastModified)(Dart_NativeArguments args) {
+ Dart_EnterScope();
+ const char* name =
+ DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
+ intptr_t return_value = File::LastModified(name);
+ if (return_value >= 0) {
+ Dart_SetReturnValue(args, Dart_NewInteger(return_value));
+ } else {
+ Dart_Handle err = DartUtils::NewDartOSError();
+ if (Dart_IsError(err)) Dart_PropagateError(err);
+ Dart_SetReturnValue(args, err);
+ }
+ Dart_ExitScope();
+}
+
+
void FUNCTION_NAME(File_Flush)(Dart_NativeArguments args) {
Dart_EnterScope();
intptr_t value =
@@ -679,6 +695,20 @@ static CObject* FileLengthFromNameRequest(const CObjectArray& request) {
}
+static CObject* FileLastModifiedRequest(const CObjectArray& request) {
+ if (request.Length() == 2 && request[1]->IsString()) {
+ CObjectString filename(request[1]);
+ intptr_t return_value = File::LastModified(filename.CString());
+ if (return_value >= 0) {
+ return new CObjectIntptr(CObject::NewIntptr(return_value));
+ } else {
+ return CObject::NewOSError();
+ }
+ }
+ return CObject::IllegalArgumentError();
+}
+
+
static CObject* FileFlushRequest(const CObjectArray& request) {
if (request.Length() == 2 && request[1]->IsIntptr()) {
File* file = CObjectToFilePointer(request[1]);
@@ -883,6 +913,9 @@ void FileService(Dart_Port dest_port_id,
case File::kLengthFromNameRequest:
response = FileLengthFromNameRequest(request);
break;
+ case File::kLastModifiedRequest:
+ response = FileLastModifiedRequest(request);
+ break;
case File::kFlushRequest:
response = FileFlushRequest(request);
break;

Powered by Google App Engine
This is Rietveld 408576698