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

Unified Diff: runtime/bin/file.cc

Issue 10065013: Support length operation without opening file. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 adfdbecaf7d13c502d3def2cad7fd0a9110c668a..1f6c6a4e864e157a83cd62e8de560d60c1632918 100644
--- a/runtime/bin/file.cc
+++ b/runtime/bin/file.cc
@@ -351,6 +351,24 @@ void FUNCTION_NAME(File_Length)(Dart_NativeArguments args) {
}
+void FUNCTION_NAME(File_LengthFromName)(Dart_NativeArguments args) {
+ Dart_EnterScope();
+ const char* name =
+ DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
+ intptr_t return_value = File::LengthFromName(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 =
@@ -667,6 +685,20 @@ static CObject* FileLengthRequest(const CObjectArray& request) {
}
+static CObject* FileLengthFromNameRequest(const CObjectArray& request) {
+ if (request.Length() == 2 && request[1]->IsString()) {
+ CObjectString filename(request[1]);
+ intptr_t return_value = File::LengthFromName(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) {
intptr_t return_value = -1;
if (request.Length() == 2 && request[1]->IsIntptr()) {
@@ -864,6 +896,9 @@ void FileService(Dart_Port dest_port_id,
case File::kLengthRequest:
response = FileLengthRequest(request);
break;
+ case File::kLengthFromNameRequest:
+ response = FileLengthFromNameRequest(request);
+ break;
case File::kFlushRequest:
response = FileFlushRequest(request);
break;
« no previous file with comments | « runtime/bin/file.h ('k') | runtime/bin/file.dart » ('j') | runtime/bin/file_impl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698