OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 FILE* file = fopen(name, "rb"); | 340 FILE* file = fopen(name, "rb"); |
341 if (file == NULL) return v8::Handle<v8::String>(); | 341 if (file == NULL) return v8::Handle<v8::String>(); |
342 | 342 |
343 fseek(file, 0, SEEK_END); | 343 fseek(file, 0, SEEK_END); |
344 int size = ftell(file); | 344 int size = ftell(file); |
345 rewind(file); | 345 rewind(file); |
346 | 346 |
347 char* chars = new char[size + 1]; | 347 char* chars = new char[size + 1]; |
348 chars[size] = '\0'; | 348 chars[size] = '\0'; |
349 for (int i = 0; i < size;) { | 349 for (int i = 0; i < size;) { |
350 int read = fread(&chars[i], 1, size - i, file); | 350 int read = static_cast<int>(fread(&chars[i], 1, size - i, file)); |
351 i += read; | 351 i += read; |
352 } | 352 } |
353 fclose(file); | 353 fclose(file); |
354 v8::Handle<v8::String> result = v8::String::New(chars, size); | 354 v8::Handle<v8::String> result = v8::String::New(chars, size); |
355 delete[] chars; | 355 delete[] chars; |
356 return result; | 356 return result; |
357 } | 357 } |
358 | 358 |
359 | 359 |
360 void ReportException(v8::TryCatch* try_catch) { | 360 void ReportException(v8::TryCatch* try_catch) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 } | 438 } |
439 // Remove newline char | 439 // Remove newline char |
440 for (char* pos = buffer; *pos != '\0'; pos++) { | 440 for (char* pos = buffer; *pos != '\0'; pos++) { |
441 if (*pos == '\n') { | 441 if (*pos == '\n') { |
442 *pos = '\0'; | 442 *pos = '\0'; |
443 break; | 443 break; |
444 } | 444 } |
445 } | 445 } |
446 return v8::String::New(buffer); | 446 return v8::String::New(buffer); |
447 } | 447 } |
OLD | NEW |