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

Unified Diff: runtime/bin/file.cc

Issue 8679005: Add truncate operation to File API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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 4037dc9f3db57c315198a1b44073d770bde88e6d..784f25854a7b8e6b46453bc9ce13ba04c3f24bea 100644
--- a/runtime/bin/file.cc
+++ b/runtime/bin/file.cc
@@ -218,7 +218,7 @@ void FUNCTION_NAME(File_Position)(Dart_NativeArguments args) {
void FUNCTION_NAME(File_SetPosition)(Dart_NativeArguments args) {
Dart_EnterScope();
- intptr_t return_value = -1;
+ bool return_value = false;
intptr_t value =
DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0));
File* file = reinterpret_cast<File*>(value);
@@ -227,7 +227,23 @@ void FUNCTION_NAME(File_SetPosition)(Dart_NativeArguments args) {
DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1));
return_value = file->SetPosition(position);
}
- Dart_SetReturnValue(args, Dart_NewInteger(return_value));
+ Dart_SetReturnValue(args, Dart_NewBoolean(return_value));
+ Dart_ExitScope();
+}
+
+
+void FUNCTION_NAME(File_Truncate)(Dart_NativeArguments args) {
+ Dart_EnterScope();
+ bool return_value = false;
+ intptr_t value =
+ DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0));
+ File* file = reinterpret_cast<File*>(value);
+ if (file != NULL) {
+ int64_t length =
+ DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1));
+ return_value = file->Truncate(length);
+ }
+ Dart_SetReturnValue(args, Dart_NewBoolean(return_value));
Dart_ExitScope();
}
« 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