Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: base/file_util_posix.cc

Issue 115229: Add support for almost-recursive watches in Linux DirectoryWatcher (Closed)
Patch Set: fix NULL file_thread scenario Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 433
434 bool GetFileInfo(const FilePath& file_path, FileInfo* results) { 434 bool GetFileInfo(const FilePath& file_path, FileInfo* results) {
435 struct stat64 file_info; 435 struct stat64 file_info;
436 if (stat64(file_path.value().c_str(), &file_info) != 0) 436 if (stat64(file_path.value().c_str(), &file_info) != 0)
437 return false; 437 return false;
438 results->is_directory = S_ISDIR(file_info.st_mode); 438 results->is_directory = S_ISDIR(file_info.st_mode);
439 results->size = file_info.st_size; 439 results->size = file_info.st_size;
440 return true; 440 return true;
441 } 441 }
442 442
443 bool GetInode(const FilePath& path, ino_t* inode) {
444 struct stat buffer;
445 int result = stat(path.value().c_str(), &buffer);
446 if (result < 0)
447 return false;
448
449 *inode = buffer.st_ino;
450 return true;
451 }
452
443 FILE* OpenFile(const std::string& filename, const char* mode) { 453 FILE* OpenFile(const std::string& filename, const char* mode) {
444 return OpenFile(FilePath(filename), mode); 454 return OpenFile(FilePath(filename), mode);
445 } 455 }
446 456
447 FILE* OpenFile(const FilePath& filename, const char* mode) { 457 FILE* OpenFile(const FilePath& filename, const char* mode) {
448 return fopen(filename.value().c_str(), mode); 458 return fopen(filename.value().c_str(), mode);
449 } 459 }
450 460
451 int ReadFile(const FilePath& filename, char* data, int size) { 461 int ReadFile(const FilePath& filename, char* data, int size) {
452 int fd = open(filename.value().c_str(), O_RDONLY); 462 int fd = open(filename.value().c_str(), O_RDONLY);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 munmap(data_, length_); 642 munmap(data_, length_);
633 if (file_ != -1) 643 if (file_ != -1)
634 close(file_); 644 close(file_);
635 645
636 data_ = NULL; 646 data_ = NULL;
637 length_ = 0; 647 length_ = 0;
638 file_ = -1; 648 file_ = -1;
639 } 649 }
640 650
641 } // namespace file_util 651 } // namespace file_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698