Chromium Code Reviews| 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 = *error_code ? PLATFORM_FILE_ERROR_FAILED : | |
|
rvargas (doing something else)
2011/06/23 03:43:53
I have no idea why this code was changed from what
Greg Billock
2011/06/23 16:58:32
Yeah, I think the previous version was right. I'll
| |
| 60 PLATFORM_FILE_OK; | |
| 59 return kInvalidPlatformFileValue; | 61 return kInvalidPlatformFileValue; |
| 60 } | 62 } |
| 61 | 63 |
| 62 if (flags & PLATFORM_FILE_WRITE && flags & PLATFORM_FILE_READ) { | 64 if (flags & PLATFORM_FILE_WRITE && flags & PLATFORM_FILE_READ) { |
| 63 open_flags |= O_RDWR; | 65 open_flags |= O_RDWR; |
| 64 } else if (flags & PLATFORM_FILE_WRITE) { | 66 } else if (flags & PLATFORM_FILE_WRITE) { |
| 65 open_flags |= O_WRONLY; | 67 open_flags |= O_WRONLY; |
| 66 } else if (!(flags & PLATFORM_FILE_READ) && | 68 } else if (!(flags & PLATFORM_FILE_READ) && |
| 67 !(flags & PLATFORM_FILE_WRITE_ATTRIBUTES) && | 69 !(flags & PLATFORM_FILE_WRITE_ATTRIBUTES) && |
| 68 !(flags & PLATFORM_FILE_OPEN_ALWAYS)) { | 70 !(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); | 188 info->is_directory = S_ISDIR(file_info.st_mode); |
| 187 info->is_symbolic_link = S_ISLNK(file_info.st_mode); | 189 info->is_symbolic_link = S_ISLNK(file_info.st_mode); |
| 188 info->size = file_info.st_size; | 190 info->size = file_info.st_size; |
| 189 info->last_modified = base::Time::FromTimeT(file_info.st_mtime); | 191 info->last_modified = base::Time::FromTimeT(file_info.st_mtime); |
| 190 info->last_accessed = base::Time::FromTimeT(file_info.st_atime); | 192 info->last_accessed = base::Time::FromTimeT(file_info.st_atime); |
| 191 info->creation_time = base::Time::FromTimeT(file_info.st_ctime); | 193 info->creation_time = base::Time::FromTimeT(file_info.st_ctime); |
| 192 return true; | 194 return true; |
| 193 } | 195 } |
| 194 | 196 |
| 195 } // namespace base | 197 } // namespace base |
| OLD | NEW |