| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 if (flags & PLATFORM_FILE_EXCLUSIVE_READ || | 77 if (flags & PLATFORM_FILE_EXCLUSIVE_READ || |
| 78 flags & PLATFORM_FILE_EXCLUSIVE_WRITE) { | 78 flags & PLATFORM_FILE_EXCLUSIVE_WRITE) { |
| 79 open_flags |= O_EXCL; // together with O_CREAT implies O_NOFOLLOW | 79 open_flags |= O_EXCL; // together with O_CREAT implies O_NOFOLLOW |
| 80 } | 80 } |
| 81 descriptor = open(name.value().c_str(), open_flags, S_IRUSR | S_IWUSR); | 81 descriptor = open(name.value().c_str(), open_flags, S_IRUSR | S_IWUSR); |
| 82 if (created && descriptor > 0) | 82 if (created && descriptor > 0) |
| 83 *created = true; | 83 *created = true; |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 if (created && (descriptor > 0) && (flags & PLATFORM_FILE_CREATE_ALWAYS)) | 87 if (created && (descriptor > 0) && |
| 88 (flags & (PLATFORM_FILE_CREATE_ALWAYS | PLATFORM_FILE_CREATE))) |
| 88 *created = true; | 89 *created = true; |
| 89 | 90 |
| 90 if ((descriptor > 0) && (flags & PLATFORM_FILE_DELETE_ON_CLOSE)) { | 91 if ((descriptor > 0) && (flags & PLATFORM_FILE_DELETE_ON_CLOSE)) { |
| 91 unlink(name.value().c_str()); | 92 unlink(name.value().c_str()); |
| 92 } | 93 } |
| 93 | 94 |
| 94 if (error_code) { | 95 if (error_code) { |
| 95 if (descriptor >= 0) | 96 if (descriptor >= 0) |
| 96 *error_code = PLATFORM_FILE_OK; | 97 *error_code = PLATFORM_FILE_OK; |
| 97 else { | 98 else { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 187 |
| 187 info->is_directory = S_ISDIR(file_info.st_mode); | 188 info->is_directory = S_ISDIR(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 |