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

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: Return ms from C 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
« no previous file with comments | « runtime/bin/file.h ('k') | runtime/bin/file.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file.cc
diff --git a/runtime/bin/file.cc b/runtime/bin/file.cc
index e9166e5b2b522614140405f9d2da7dc2b1718800..ecc3cc70445c90cd4558c5152335d3630b9fb667 100644
--- a/runtime/bin/file.cc
+++ b/runtime/bin/file.cc
@@ -11,6 +11,8 @@
#include "include/dart_api.h"
+static const int kMSPerSecond = 1000;
+
dart::Mutex File::mutex_;
int File::service_ports_size_ = 0;
Dart_Port* File::service_ports_ = NULL;
@@ -357,6 +359,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));
+ int64_t return_value = File::LastModified(name);
+ if (return_value >= 0) {
+ Dart_SetReturnValue(args, Dart_NewInteger(return_value * kMSPerSecond));
+ } 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 +697,20 @@ static CObject* FileLengthFromNameRequest(const CObjectArray& request) {
}
+static CObject* FileLastModifiedRequest(const CObjectArray& request) {
+ if (request.Length() == 2 && request[1]->IsString()) {
+ CObjectString filename(request[1]);
+ int64_t return_value = File::LastModified(filename.CString());
+ if (return_value >= 0) {
+ return new CObjectIntptr(CObject::NewInt64(return_value * kMSPerSecond));
+ } 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 +915,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;
« no previous file with comments | « runtime/bin/file.h ('k') | runtime/bin/file.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698