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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 !(flags & PLATFORM_FILE_OPEN_ALWAYS)) { | 45 !(flags & PLATFORM_FILE_OPEN_ALWAYS)) { |
46 NOTREACHED(); | 46 NOTREACHED(); |
47 errno = EOPNOTSUPP; | 47 errno = EOPNOTSUPP; |
48 if (error_code) | 48 if (error_code) |
49 *error_code = PLATFORM_FILE_ERROR_FAILED; | 49 *error_code = PLATFORM_FILE_ERROR_FAILED; |
50 return kInvalidPlatformFileValue; | 50 return kInvalidPlatformFileValue; |
51 } | 51 } |
52 | 52 |
53 if (flags & PLATFORM_FILE_WRITE && flags & PLATFORM_FILE_READ) { | 53 if (flags & PLATFORM_FILE_WRITE && flags & PLATFORM_FILE_READ) { |
54 open_flags |= O_RDWR; | 54 open_flags |= O_RDWR; |
55 } else if (flags & PLATFORM_FILE_WRITE) { | 55 } else if (flags & PLATFORM_FILE_WRITE || |
| 56 flags & PLATFORM_FILE_WRITE_ATTRIBUTES) { |
56 open_flags |= O_WRONLY; | 57 open_flags |= O_WRONLY; |
57 } else if (!(flags & PLATFORM_FILE_READ)) { | 58 } else if (!(flags & PLATFORM_FILE_READ)) { |
58 NOTREACHED(); | 59 NOTREACHED(); |
59 } | 60 } |
60 | 61 |
61 if (flags & PLATFORM_FILE_TRUNCATE) { | 62 if (flags & PLATFORM_FILE_TRUNCATE) { |
62 DCHECK(flags & PLATFORM_FILE_WRITE); | 63 DCHECK(flags & PLATFORM_FILE_WRITE); |
63 open_flags |= O_TRUNC; | 64 open_flags |= O_TRUNC; |
64 } | 65 } |
65 | 66 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 186 |
186 info->is_directory = S_ISDIR(file_info.st_mode); | 187 info->is_directory = S_ISDIR(file_info.st_mode); |
187 info->size = file_info.st_size; | 188 info->size = file_info.st_size; |
188 info->last_modified = base::Time::FromTimeT(file_info.st_mtime); | 189 info->last_modified = base::Time::FromTimeT(file_info.st_mtime); |
189 info->last_accessed = base::Time::FromTimeT(file_info.st_atime); | 190 info->last_accessed = base::Time::FromTimeT(file_info.st_atime); |
190 info->creation_time = base::Time::FromTimeT(file_info.st_ctime); | 191 info->creation_time = base::Time::FromTimeT(file_info.st_ctime); |
191 return true; | 192 return true; |
192 } | 193 } |
193 | 194 |
194 } // namespace base | 195 } // namespace base |
OLD | NEW |