OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/platform_file.h" | 5 #include "base/platform_file.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 | 10 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 !(flags & PLATFORM_FILE_WRITE_ATTRIBUTES) && | 58 !(flags & PLATFORM_FILE_WRITE_ATTRIBUTES) && |
59 !(flags & PLATFORM_FILE_OPEN_ALWAYS)) { | 59 !(flags & PLATFORM_FILE_OPEN_ALWAYS)) { |
60 NOTREACHED(); | 60 NOTREACHED(); |
61 } | 61 } |
62 | 62 |
63 if (flags & PLATFORM_FILE_TRUNCATE) { | 63 if (flags & PLATFORM_FILE_TRUNCATE) { |
64 DCHECK(flags & PLATFORM_FILE_WRITE); | 64 DCHECK(flags & PLATFORM_FILE_WRITE); |
65 open_flags |= O_TRUNC; | 65 open_flags |= O_TRUNC; |
66 } | 66 } |
67 | 67 |
68 DCHECK(O_RDONLY == 0); | 68 COMPILE_ASSERT(O_RDONLY == 0, O_RDONLY_must_equal_zero); |
69 | 69 |
70 int descriptor = open(name.value().c_str(), open_flags, S_IRUSR | S_IWUSR); | 70 int descriptor = open(name.value().c_str(), open_flags, S_IRUSR | S_IWUSR); |
71 | 71 |
72 if (flags & PLATFORM_FILE_OPEN_ALWAYS) { | 72 if (flags & PLATFORM_FILE_OPEN_ALWAYS) { |
73 if (descriptor > 0) { | 73 if (descriptor > 0) { |
74 if (created) | 74 if (created) |
75 *created = false; | 75 *created = false; |
76 } else { | 76 } else { |
77 open_flags |= O_CREAT; | 77 open_flags |= O_CREAT; |
78 if (flags & PLATFORM_FILE_EXCLUSIVE_READ || | 78 if (flags & PLATFORM_FILE_EXCLUSIVE_READ || |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 info->is_directory = S_ISDIR(file_info.st_mode); | 189 info->is_directory = S_ISDIR(file_info.st_mode); |
190 info->is_symbolic_link = S_ISLNK(file_info.st_mode); | 190 info->is_symbolic_link = S_ISLNK(file_info.st_mode); |
191 info->size = file_info.st_size; | 191 info->size = file_info.st_size; |
192 info->last_modified = base::Time::FromTimeT(file_info.st_mtime); | 192 info->last_modified = base::Time::FromTimeT(file_info.st_mtime); |
193 info->last_accessed = base::Time::FromTimeT(file_info.st_atime); | 193 info->last_accessed = base::Time::FromTimeT(file_info.st_atime); |
194 info->creation_time = base::Time::FromTimeT(file_info.st_ctime); | 194 info->creation_time = base::Time::FromTimeT(file_info.st_ctime); |
195 return true; | 195 return true; |
196 } | 196 } |
197 | 197 |
198 } // namespace base | 198 } // namespace base |
OLD | NEW |