Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: base/platform_file_posix.cc

Issue 13818027: posix: replace nonstandard futimes call with futimens (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change Time::ToTimeVal to Time::ToTimeSpec Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/platform_file_unittest.cc » ('j') | base/time.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 timespec times[2];
302 times[0] = last_access_time.ToTimeVal(); 302 times[0] = last_access_time.ToTimeSpec();
303 times[1] = last_modified_time.ToTimeVal(); 303 times[1] = last_modified_time.ToTimeSpec();
304 return !futimes(file, times); 304
305 return !futimens(file, times);
305 } 306 }
306 307
307 bool GetPlatformFileInfo(PlatformFile file, PlatformFileInfo* info) { 308 bool GetPlatformFileInfo(PlatformFile file, PlatformFileInfo* info) {
308 if (!info) 309 if (!info)
309 return false; 310 return false;
310 311
311 stat_wrapper_t file_info; 312 stat_wrapper_t file_info;
312 if (CallFstat(file, &file_info)) 313 if (CallFstat(file, &file_info))
313 return false; 314 return false;
314 315
315 info->is_directory = S_ISDIR(file_info.st_mode); 316 info->is_directory = S_ISDIR(file_info.st_mode);
316 info->is_symbolic_link = S_ISLNK(file_info.st_mode); 317 info->is_symbolic_link = S_ISLNK(file_info.st_mode);
317 info->size = file_info.st_size; 318 info->size = file_info.st_size;
318 info->last_modified = base::Time::FromTimeT(file_info.st_mtime); 319 info->last_modified = base::Time::FromTimeT(file_info.st_mtime);
319 info->last_accessed = base::Time::FromTimeT(file_info.st_atime); 320 info->last_accessed = base::Time::FromTimeT(file_info.st_atime);
320 info->creation_time = base::Time::FromTimeT(file_info.st_ctime); 321 info->creation_time = base::Time::FromTimeT(file_info.st_ctime);
321 return true; 322 return true;
322 } 323 }
323 324
324 } // namespace base 325 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/platform_file_unittest.cc » ('j') | base/time.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698