Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 base::ThreadRestrictions::AssertIOAllowed(); | 291 base::ThreadRestrictions::AssertIOAllowed(); |
| 292 return !HANDLE_EINTR(fsync(file)); | 292 return !HANDLE_EINTR(fsync(file)); |
| 293 } | 293 } |
| 294 | 294 |
| 295 bool TouchPlatformFile(PlatformFile file, const base::Time& last_access_time, | 295 bool TouchPlatformFile(PlatformFile file, const base::Time& last_access_time, |
| 296 const base::Time& last_modified_time) { | 296 const base::Time& last_modified_time) { |
| 297 base::ThreadRestrictions::AssertIOAllowed(); | 297 base::ThreadRestrictions::AssertIOAllowed(); |
| 298 if (file < 0) | 298 if (file < 0) |
| 299 return false; | 299 return false; |
| 300 | 300 |
| 301 timeval times[2]; | 301 timeval tv[2]; |
| 302 times[0] = last_access_time.ToTimeVal(); | 302 tv[0] = last_access_time.ToTimeVal(); |
|
darin (slow to review)
2013/04/10 17:51:05
nit: The code might be more readable with named va
Mostyn Bramley-Moore
2013/04/10 20:59:07
Done.
| |
| 303 times[1] = last_modified_time.ToTimeVal(); | 303 tv[1] = last_modified_time.ToTimeVal(); |
| 304 return !futimes(file, times); | 304 |
| 305 timespec ts[2]; | |
| 306 ts[0].tv_sec = tv[0].tv_sec; | |
| 307 ts[0].tv_nsec = tv[0].tv_usec * 1000; | |
| 308 ts[1].tv_sec = tv[1].tv_sec; | |
| 309 ts[1].tv_nsec = tv[1].tv_usec * 1000; | |
| 310 | |
| 311 return !futimens(file, ts); | |
| 305 } | 312 } |
| 306 | 313 |
| 307 bool GetPlatformFileInfo(PlatformFile file, PlatformFileInfo* info) { | 314 bool GetPlatformFileInfo(PlatformFile file, PlatformFileInfo* info) { |
| 308 if (!info) | 315 if (!info) |
| 309 return false; | 316 return false; |
| 310 | 317 |
| 311 stat_wrapper_t file_info; | 318 stat_wrapper_t file_info; |
| 312 if (CallFstat(file, &file_info)) | 319 if (CallFstat(file, &file_info)) |
| 313 return false; | 320 return false; |
| 314 | 321 |
| 315 info->is_directory = S_ISDIR(file_info.st_mode); | 322 info->is_directory = S_ISDIR(file_info.st_mode); |
| 316 info->is_symbolic_link = S_ISLNK(file_info.st_mode); | 323 info->is_symbolic_link = S_ISLNK(file_info.st_mode); |
| 317 info->size = file_info.st_size; | 324 info->size = file_info.st_size; |
| 318 info->last_modified = base::Time::FromTimeT(file_info.st_mtime); | 325 info->last_modified = base::Time::FromTimeT(file_info.st_mtime); |
| 319 info->last_accessed = base::Time::FromTimeT(file_info.st_atime); | 326 info->last_accessed = base::Time::FromTimeT(file_info.st_atime); |
| 320 info->creation_time = base::Time::FromTimeT(file_info.st_ctime); | 327 info->creation_time = base::Time::FromTimeT(file_info.st_ctime); |
| 321 return true; | 328 return true; |
| 322 } | 329 } |
| 323 | 330 |
| 324 } // namespace base | 331 } // namespace base |
| OLD | NEW |