OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <unistd.h> | 10 #include <unistd.h> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 if (flags & PLATFORM_FILE_OPEN_TRUNCATED) { | 48 if (flags & PLATFORM_FILE_OPEN_TRUNCATED) { |
49 DCHECK(!open_flags); | 49 DCHECK(!open_flags); |
50 DCHECK(flags & PLATFORM_FILE_WRITE); | 50 DCHECK(flags & PLATFORM_FILE_WRITE); |
51 open_flags = O_TRUNC; | 51 open_flags = O_TRUNC; |
52 } | 52 } |
53 | 53 |
54 if (!open_flags && !(flags & PLATFORM_FILE_OPEN) && | 54 if (!open_flags && !(flags & PLATFORM_FILE_OPEN) && |
55 !(flags & PLATFORM_FILE_OPEN_ALWAYS)) { | 55 !(flags & PLATFORM_FILE_OPEN_ALWAYS)) { |
56 NOTREACHED(); | 56 NOTREACHED(); |
57 errno = EOPNOTSUPP; | 57 errno = EOPNOTSUPP; |
58 *error_code = error_code ? PLATFORM_FILE_ERROR_FAILED : PLATFORM_FILE_OK; | 58 if (error_code) |
| 59 *error_code = PLATFORM_FILE_ERROR_FAILED; |
59 return kInvalidPlatformFileValue; | 60 return kInvalidPlatformFileValue; |
60 } | 61 } |
61 | 62 |
62 if (flags & PLATFORM_FILE_WRITE && flags & PLATFORM_FILE_READ) { | 63 if (flags & PLATFORM_FILE_WRITE && flags & PLATFORM_FILE_READ) { |
63 open_flags |= O_RDWR; | 64 open_flags |= O_RDWR; |
64 } else if (flags & PLATFORM_FILE_WRITE) { | 65 } else if (flags & PLATFORM_FILE_WRITE) { |
65 open_flags |= O_WRONLY; | 66 open_flags |= O_WRONLY; |
66 } else if (!(flags & PLATFORM_FILE_READ) && | 67 } else if (!(flags & PLATFORM_FILE_READ) && |
67 !(flags & PLATFORM_FILE_WRITE_ATTRIBUTES) && | 68 !(flags & PLATFORM_FILE_WRITE_ATTRIBUTES) && |
68 !(flags & PLATFORM_FILE_OPEN_ALWAYS)) { | 69 !(flags & PLATFORM_FILE_OPEN_ALWAYS)) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 info->is_directory = S_ISDIR(file_info.st_mode); | 187 info->is_directory = S_ISDIR(file_info.st_mode); |
187 info->is_symbolic_link = S_ISLNK(file_info.st_mode); | 188 info->is_symbolic_link = S_ISLNK(file_info.st_mode); |
188 info->size = file_info.st_size; | 189 info->size = file_info.st_size; |
189 info->last_modified = base::Time::FromTimeT(file_info.st_mtime); | 190 info->last_modified = base::Time::FromTimeT(file_info.st_mtime); |
190 info->last_accessed = base::Time::FromTimeT(file_info.st_atime); | 191 info->last_accessed = base::Time::FromTimeT(file_info.st_atime); |
191 info->creation_time = base::Time::FromTimeT(file_info.st_ctime); | 192 info->creation_time = base::Time::FromTimeT(file_info.st_ctime); |
192 return true; | 193 return true; |
193 } | 194 } |
194 | 195 |
195 } // namespace base | 196 } // namespace base |
OLD | NEW |