Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 ASSERT((offset + length) <= array_len); | 152 ASSERT((offset + length) <= array_len); |
| 153 uint8_t* buffer = new uint8_t[length]; | 153 uint8_t* buffer = new uint8_t[length]; |
| 154 int total_bytes_read = | 154 int total_bytes_read = |
| 155 file->Read(reinterpret_cast<void*>(buffer), length); | 155 file->Read(reinterpret_cast<void*>(buffer), length); |
| 156 /* | 156 /* |
| 157 * Reading 0 indicates end of file. | 157 * Reading 0 indicates end of file. |
| 158 */ | 158 */ |
| 159 if (total_bytes_read >= 0) { | 159 if (total_bytes_read >= 0) { |
| 160 result = | 160 result = |
| 161 Dart_ListSetAsBytes(buffer_obj, offset, buffer, total_bytes_read); | 161 Dart_ListSetAsBytes(buffer_obj, offset, buffer, total_bytes_read); |
| 162 ASSERT(!Dart_IsError(result)); | 162 if (!Dart_IsError(result)) { |
| 163 return_value = total_bytes_read; | 163 return_value = total_bytes_read; |
|
turnidge
2011/11/16 18:50:18
There's probably some good diagnostic information
| |
| 164 } | |
| 164 } | 165 } |
| 165 delete[] buffer; | 166 delete[] buffer; |
| 166 } | 167 } |
| 167 Dart_SetReturnValue(args, Dart_NewInteger(return_value)); | 168 Dart_SetReturnValue(args, Dart_NewInteger(return_value)); |
| 168 Dart_ExitScope(); | 169 Dart_ExitScope(); |
| 169 } | 170 } |
| 170 | 171 |
| 171 | 172 |
| 172 void FUNCTION_NAME(File_WriteList)(Dart_NativeArguments args) { | 173 void FUNCTION_NAME(File_WriteList)(Dart_NativeArguments args) { |
| 173 Dart_EnterScope(); | 174 Dart_EnterScope(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 Dart_EnterScope(); | 259 Dart_EnterScope(); |
| 259 const char* str = | 260 const char* str = |
| 260 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); | 261 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); |
| 261 char* path = File::GetCanonicalPath(str); | 262 char* path = File::GetCanonicalPath(str); |
| 262 if (path != NULL) { | 263 if (path != NULL) { |
| 263 Dart_SetReturnValue(args, Dart_NewString(path)); | 264 Dart_SetReturnValue(args, Dart_NewString(path)); |
| 264 free(path); | 265 free(path); |
| 265 } | 266 } |
| 266 Dart_ExitScope(); | 267 Dart_ExitScope(); |
| 267 } | 268 } |
| OLD | NEW |