| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <errno.h> | 5 #include <errno.h> |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 void Shell::Write(const v8::FunctionCallbackInfo<v8::Value>& args) { | 1189 void Shell::Write(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 1190 WriteToFile(stdout, args); | 1190 WriteToFile(stdout, args); |
| 1191 } | 1191 } |
| 1192 | 1192 |
| 1193 void Shell::Read(const v8::FunctionCallbackInfo<v8::Value>& args) { | 1193 void Shell::Read(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 1194 String::Utf8Value file(args[0]); | 1194 String::Utf8Value file(args[0]); |
| 1195 if (*file == NULL) { | 1195 if (*file == NULL) { |
| 1196 Throw(args.GetIsolate(), "Error loading file"); | 1196 Throw(args.GetIsolate(), "Error loading file"); |
| 1197 return; | 1197 return; |
| 1198 } | 1198 } |
| 1199 if (args.Length() == 2) { |
| 1200 String::Utf8Value format(args[1]); |
| 1201 if (*format && std::strcmp(*format, "binary") == 0) { |
| 1202 ReadBuffer(args); |
| 1203 return; |
| 1204 } |
| 1205 } |
| 1199 Local<String> source = ReadFile(args.GetIsolate(), *file); | 1206 Local<String> source = ReadFile(args.GetIsolate(), *file); |
| 1200 if (source.IsEmpty()) { | 1207 if (source.IsEmpty()) { |
| 1201 Throw(args.GetIsolate(), "Error loading file"); | 1208 Throw(args.GetIsolate(), "Error loading file"); |
| 1202 return; | 1209 return; |
| 1203 } | 1210 } |
| 1204 args.GetReturnValue().Set(source); | 1211 args.GetReturnValue().Set(source); |
| 1205 } | 1212 } |
| 1206 | 1213 |
| 1207 | 1214 |
| 1208 Local<String> Shell::ReadFromStdin(Isolate* isolate) { | 1215 Local<String> Shell::ReadFromStdin(Isolate* isolate) { |
| (...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3197 } | 3204 } |
| 3198 | 3205 |
| 3199 } // namespace v8 | 3206 } // namespace v8 |
| 3200 | 3207 |
| 3201 | 3208 |
| 3202 #ifndef GOOGLE3 | 3209 #ifndef GOOGLE3 |
| 3203 int main(int argc, char* argv[]) { | 3210 int main(int argc, char* argv[]) { |
| 3204 return v8::Shell::Main(argc, argv); | 3211 return v8::Shell::Main(argc, argv); |
| 3205 } | 3212 } |
| 3206 #endif | 3213 #endif |
| OLD | NEW |