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

Side by Side Diff: base/file_util_posix.cc

Issue 3347005: Moving file_util::FileInfo to base::PlatformFileInfo, and adding the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/file_util.h" 5 #include "base/file_util.h"
6 6
7 #include <dirent.h> 7 #include <dirent.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <fnmatch.h> 10 #include <fnmatch.h>
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 // Mkdir failed, but it might have failed with EEXIST, or some other error 467 // Mkdir failed, but it might have failed with EEXIST, or some other error
468 // due to the the directory appearing out of thin air. This can occur if 468 // due to the the directory appearing out of thin air. This can occur if
469 // two processes are trying to create the same file system tree at the same 469 // two processes are trying to create the same file system tree at the same
470 // time. Check to see if it exists and make sure it is a directory. 470 // time. Check to see if it exists and make sure it is a directory.
471 if (!DirectoryExists(*i)) 471 if (!DirectoryExists(*i))
472 return false; 472 return false;
473 } 473 }
474 return true; 474 return true;
475 } 475 }
476 476
477 bool GetFileInfo(const FilePath& file_path, FileInfo* results) { 477 bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) {
478 stat_wrapper_t file_info; 478 stat_wrapper_t file_info;
479 if (CallStat(file_path.value().c_str(), &file_info) != 0) 479 if (CallStat(file_path.value().c_str(), &file_info) != 0)
480 return false; 480 return false;
481 results->is_directory = S_ISDIR(file_info.st_mode); 481 results->is_directory = S_ISDIR(file_info.st_mode);
482 results->size = file_info.st_size; 482 results->size = file_info.st_size;
483 results->last_modified = base::Time::FromTimeT(file_info.st_mtime); 483 results->last_modified = base::Time::FromTimeT(file_info.st_mtime);
484 results->last_accessed = base::Time::FromTimeT(file_info.st_atime);
485 results->creation_time = base::Time::FromTimeT(file_info.st_ctime);
484 return true; 486 return true;
485 } 487 }
486 488
487 bool SetLastModifiedTime(const FilePath& file_path, base::Time last_modified) { 489 bool SetLastModifiedTime(const FilePath& file_path, base::Time last_modified) {
488 struct timeval times[2]; 490 struct timeval times[2];
489 times[0] = last_modified.ToTimeVal(); 491 times[0] = last_modified.ToTimeVal();
490 times[1] = last_modified.ToTimeVal(); 492 times[1] = last_modified.ToTimeVal();
491 return (utimes(file_path.value().c_str(), times) == 0); 493 return (utimes(file_path.value().c_str(), times) == 0);
492 } 494 }
493 495
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 if (HANDLE_EINTR(close(infile)) < 0) 835 if (HANDLE_EINTR(close(infile)) < 0)
834 result = false; 836 result = false;
835 if (HANDLE_EINTR(close(outfile)) < 0) 837 if (HANDLE_EINTR(close(outfile)) < 0)
836 result = false; 838 result = false;
837 839
838 return result; 840 return result;
839 } 841 }
840 #endif // defined(OS_MACOSX) 842 #endif // defined(OS_MACOSX)
841 843
842 } // namespace file_util 844 } // namespace file_util
OLDNEW
« no previous file with comments | « base/file_util.cc ('k') | base/file_util_proxy.h » ('j') | base/platform_file.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698