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

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: 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 | no next file » | no next file with comments »
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 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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698