| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 | 6 |
| 7 #include <dirent.h> | 7 #include <dirent.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <fnmatch.h> | 10 #include <fnmatch.h> |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 | 434 |
| 435 bool GetFileInfo(const FilePath& file_path, FileInfo* results) { | 435 bool GetFileInfo(const FilePath& file_path, FileInfo* results) { |
| 436 struct stat64 file_info; | 436 struct stat64 file_info; |
| 437 if (stat64(file_path.value().c_str(), &file_info) != 0) | 437 if (stat64(file_path.value().c_str(), &file_info) != 0) |
| 438 return false; | 438 return false; |
| 439 results->is_directory = S_ISDIR(file_info.st_mode); | 439 results->is_directory = S_ISDIR(file_info.st_mode); |
| 440 results->size = file_info.st_size; | 440 results->size = file_info.st_size; |
| 441 return true; | 441 return true; |
| 442 } | 442 } |
| 443 | 443 |
| 444 bool GetInode(const FilePath& path, ino_t* inode) { |
| 445 struct stat buffer; |
| 446 int result = stat(path.value().c_str(), &buffer); |
| 447 if (result < 0) |
| 448 return false; |
| 449 |
| 450 *inode = buffer.st_ino; |
| 451 return true; |
| 452 } |
| 453 |
| 444 FILE* OpenFile(const std::string& filename, const char* mode) { | 454 FILE* OpenFile(const std::string& filename, const char* mode) { |
| 445 return OpenFile(FilePath(filename), mode); | 455 return OpenFile(FilePath(filename), mode); |
| 446 } | 456 } |
| 447 | 457 |
| 448 FILE* OpenFile(const FilePath& filename, const char* mode) { | 458 FILE* OpenFile(const FilePath& filename, const char* mode) { |
| 449 return fopen(filename.value().c_str(), mode); | 459 return fopen(filename.value().c_str(), mode); |
| 450 } | 460 } |
| 451 | 461 |
| 452 int ReadFile(const FilePath& filename, char* data, int size) { | 462 int ReadFile(const FilePath& filename, char* data, int size) { |
| 453 int fd = open(filename.value().c_str(), O_RDONLY); | 463 int fd = open(filename.value().c_str(), O_RDONLY); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 munmap(data_, length_); | 643 munmap(data_, length_); |
| 634 if (file_ != -1) | 644 if (file_ != -1) |
| 635 close(file_); | 645 close(file_); |
| 636 | 646 |
| 637 data_ = NULL; | 647 data_ = NULL; |
| 638 length_ = 0; | 648 length_ = 0; |
| 639 file_ = -1; | 649 file_ = -1; |
| 640 } | 650 } |
| 641 | 651 |
| 642 } // namespace file_util | 652 } // namespace file_util |
| OLD | NEW |