| 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) { | |
| 57 open_flags |= O_WRONLY; | 56 open_flags |= O_WRONLY; |
| 58 } else if (!(flags & PLATFORM_FILE_READ)) { | 57 } else if (!(flags & PLATFORM_FILE_READ)) { |
| 59 NOTREACHED(); | 58 NOTREACHED(); |
| 60 } | 59 } |
| 61 | 60 |
| 62 if (flags & PLATFORM_FILE_TRUNCATE) { | 61 if (flags & PLATFORM_FILE_TRUNCATE) { |
| 63 DCHECK(flags & PLATFORM_FILE_WRITE); | 62 DCHECK(flags & PLATFORM_FILE_WRITE); |
| 64 open_flags |= O_TRUNC; | 63 open_flags |= O_TRUNC; |
| 65 } | 64 } |
| 66 | 65 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 185 |
| 187 info->is_directory = S_ISDIR(file_info.st_mode); | 186 info->is_directory = S_ISDIR(file_info.st_mode); |
| 188 info->size = file_info.st_size; | 187 info->size = file_info.st_size; |
| 189 info->last_modified = base::Time::FromTimeT(file_info.st_mtime); | 188 info->last_modified = base::Time::FromTimeT(file_info.st_mtime); |
| 190 info->last_accessed = base::Time::FromTimeT(file_info.st_atime); | 189 info->last_accessed = base::Time::FromTimeT(file_info.st_atime); |
| 191 info->creation_time = base::Time::FromTimeT(file_info.st_ctime); | 190 info->creation_time = base::Time::FromTimeT(file_info.st_ctime); |
| 192 return true; | 191 return true; |
| 193 } | 192 } |
| 194 | 193 |
| 195 } // namespace base | 194 } // namespace base |
| OLD | NEW |