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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/file.h ('k') | runtime/bin/file.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/file.h" 5 #include "bin/file.h"
6 6
7 #include "bin/builtin.h" 7 #include "bin/builtin.h"
8 #include "bin/dartutils.h" 8 #include "bin/dartutils.h"
9 9
10 #include "include/dart_api.h" 10 #include "include/dart_api.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 if (file != NULL) { 211 if (file != NULL) {
212 return_value = file->Position(); 212 return_value = file->Position();
213 } 213 }
214 Dart_SetReturnValue(args, Dart_NewInteger(return_value)); 214 Dart_SetReturnValue(args, Dart_NewInteger(return_value));
215 Dart_ExitScope(); 215 Dart_ExitScope();
216 } 216 }
217 217
218 218
219 void FUNCTION_NAME(File_SetPosition)(Dart_NativeArguments args) { 219 void FUNCTION_NAME(File_SetPosition)(Dart_NativeArguments args) {
220 Dart_EnterScope(); 220 Dart_EnterScope();
221 intptr_t return_value = -1; 221 bool return_value = false;
222 intptr_t value = 222 intptr_t value =
223 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0)); 223 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0));
224 File* file = reinterpret_cast<File*>(value); 224 File* file = reinterpret_cast<File*>(value);
225 if (file != NULL) { 225 if (file != NULL) {
226 int64_t position = 226 int64_t position =
227 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1)); 227 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1));
228 return_value = file->SetPosition(position); 228 return_value = file->SetPosition(position);
229 } 229 }
230 Dart_SetReturnValue(args, Dart_NewInteger(return_value)); 230 Dart_SetReturnValue(args, Dart_NewBoolean(return_value));
231 Dart_ExitScope(); 231 Dart_ExitScope();
232 } 232 }
233 233
234
235 void FUNCTION_NAME(File_Truncate)(Dart_NativeArguments args) {
236 Dart_EnterScope();
237 bool return_value = false;
238 intptr_t value =
239 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0));
240 File* file = reinterpret_cast<File*>(value);
241 if (file != NULL) {
242 int64_t length =
243 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1));
244 return_value = file->Truncate(length);
245 }
246 Dart_SetReturnValue(args, Dart_NewBoolean(return_value));
247 Dart_ExitScope();
248 }
249
234 250
235 void FUNCTION_NAME(File_Length)(Dart_NativeArguments args) { 251 void FUNCTION_NAME(File_Length)(Dart_NativeArguments args) {
236 Dart_EnterScope(); 252 Dart_EnterScope();
237 intptr_t return_value = -1; 253 intptr_t return_value = -1;
238 intptr_t value = 254 intptr_t value =
239 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0)); 255 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0));
240 File* file = reinterpret_cast<File*>(value); 256 File* file = reinterpret_cast<File*>(value);
241 if (file != NULL) { 257 if (file != NULL) {
242 return_value = file->Length(); 258 return_value = file->Length();
243 } 259 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 Dart_EnterScope(); 301 Dart_EnterScope();
286 const char* str = 302 const char* str =
287 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); 303 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
288 char* path = File::GetCanonicalPath(str); 304 char* path = File::GetCanonicalPath(str);
289 if (path != NULL) { 305 if (path != NULL) {
290 Dart_SetReturnValue(args, Dart_NewString(path)); 306 Dart_SetReturnValue(args, Dart_NewString(path));
291 free(path); 307 free(path);
292 } 308 }
293 Dart_ExitScope(); 309 Dart_ExitScope();
294 } 310 }
OLDNEW
« 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