| 293 | const char* const DebugIO::kHashTag = "hash"; |
| 294 | |
| 295 | Status ReadEventFromFile(const string& dump_file_path, Event* event) { |
| 296 | Env* env(Env::Default()); |
| 297 | |
| 298 | string content; |
| 299 | uint64 file_size = 0; |
| 300 | |
| 301 | Status s = env->GetFileSize(dump_file_path, &file_size); |
| 302 | if (!s.ok()) { |
| 303 | return s; |
| 304 | } |
| 305 | |
| 306 | content.resize(file_size); |
| 307 | |
| 308 | std::unique_ptr<RandomAccessFile> file; |
| 309 | s = env->NewRandomAccessFile(dump_file_path, &file); |
| 310 | if (!s.ok()) { |
| 311 | return s; |
| 312 | } |
| 313 | |
| 314 | StringPiece result; |
| 315 | s = file->Read(0, file_size, &result, &(content)[0]); |
| 316 | if (!s.ok()) { |
| 317 | return s; |
| 318 | } |
| 319 | |
| 320 | event->ParseFromString(content); |
| 321 | return Status::OK(); |
| 322 | } |
| 323 | |
| 324 | const char* const DebugIO::kFileURLScheme = "file://"; |
| 325 | const char* const DebugIO::kGrpcURLScheme = "grpc://"; |