OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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> |
11 #include <libgen.h> | 11 #include <libgen.h> |
12 #include <stdio.h> | 12 #include <stdio.h> |
13 #include <stdlib.h> | 13 #include <stdlib.h> |
14 #include <string.h> | 14 #include <string.h> |
15 #include <sys/errno.h> | 15 #include <sys/errno.h> |
16 #include <sys/mman.h> | 16 #include <sys/mman.h> |
17 #include <sys/param.h> | |
Lei Zhang
2010/05/12 18:53:32
nit: My Linux man page says this should be <limits
Sam Kerner (Chrome)
2010/05/12 20:02:57
I used the mac man page, then tested on linux...
| |
17 #include <sys/stat.h> | 18 #include <sys/stat.h> |
18 #include <sys/time.h> | 19 #include <sys/time.h> |
19 #include <sys/types.h> | 20 #include <sys/types.h> |
20 #include <time.h> | 21 #include <time.h> |
21 #include <unistd.h> | 22 #include <unistd.h> |
22 | 23 |
23 #if defined(OS_MACOSX) | 24 #if defined(OS_MACOSX) |
24 #include <AvailabilityMacros.h> | 25 #include <AvailabilityMacros.h> |
25 #else | 26 #else |
26 #include <glib.h> | 27 #include <glib.h> |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
728 data_ = NULL; | 729 data_ = NULL; |
729 length_ = 0; | 730 length_ = 0; |
730 file_ = base::kInvalidPlatformFileValue; | 731 file_ = base::kInvalidPlatformFileValue; |
731 } | 732 } |
732 | 733 |
733 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, | 734 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, |
734 const base::Time& cutoff_time) { | 735 const base::Time& cutoff_time) { |
735 return find_info.stat.st_mtime >= cutoff_time.ToTimeT(); | 736 return find_info.stat.st_mtime >= cutoff_time.ToTimeT(); |
736 } | 737 } |
737 | 738 |
739 bool RealPath(const FilePath& path, FilePath* real_path) { | |
740 FilePath::CharType buf[PATH_MAX]; | |
741 if (!realpath(path.value().c_str(), buf)) | |
742 return false; | |
743 | |
744 *real_path = FilePath(buf); | |
745 return true; | |
746 } | |
747 | |
738 #if !defined(OS_MACOSX) | 748 #if !defined(OS_MACOSX) |
739 bool GetTempDir(FilePath* path) { | 749 bool GetTempDir(FilePath* path) { |
740 const char* tmp = getenv("TMPDIR"); | 750 const char* tmp = getenv("TMPDIR"); |
741 if (tmp) | 751 if (tmp) |
742 *path = FilePath(tmp); | 752 *path = FilePath(tmp); |
743 else | 753 else |
744 *path = FilePath("/tmp"); | 754 *path = FilePath("/tmp"); |
745 return true; | 755 return true; |
746 } | 756 } |
747 | 757 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
808 if (HANDLE_EINTR(close(infile)) < 0) | 818 if (HANDLE_EINTR(close(infile)) < 0) |
809 result = false; | 819 result = false; |
810 if (HANDLE_EINTR(close(outfile)) < 0) | 820 if (HANDLE_EINTR(close(outfile)) < 0) |
811 result = false; | 821 result = false; |
812 | 822 |
813 return result; | 823 return result; |
814 } | 824 } |
815 #endif // defined(OS_MACOSX) | 825 #endif // defined(OS_MACOSX) |
816 | 826 |
817 } // namespace file_util | 827 } // namespace file_util |
OLD | NEW |