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

Side by Side Diff: base/files/file.h

Issue 203873002: Base: Make file_util and file use the same code to translate from stat to File::Info (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove TODO Created 6 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 | Annotate | Revision Log
« no previous file with comments | « base/file_util_posix.cc ('k') | base/files/file_posix.cc » ('j') | 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 #ifndef BASE_FILES_FILE_H_ 5 #ifndef BASE_FILES_FILE_H_
6 #define BASE_FILES_FILE_H_ 6 #define BASE_FILES_FILE_H_
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
11 #endif 11 #endif
12 12
13 #if defined(OS_POSIX)
14 #include <sys/stat.h>
15 #endif
16
13 #include "base/base_export.h" 17 #include "base/base_export.h"
14 #include "base/basictypes.h" 18 #include "base/basictypes.h"
15 #include "base/files/scoped_file.h" 19 #include "base/files/scoped_file.h"
16 #include "base/move.h" 20 #include "base/move.h"
17 #include "base/time/time.h" 21 #include "base/time/time.h"
18 22
19 #if defined(OS_WIN) 23 #if defined(OS_WIN)
20 #include "base/win/scoped_handle.h" 24 #include "base/win/scoped_handle.h"
21 #endif 25 #endif
22 26
23 namespace base { 27 namespace base {
24 28
25 class FilePath; 29 class FilePath;
26 30
27 #if defined(OS_WIN) 31 #if defined(OS_WIN)
28 typedef HANDLE PlatformFile; 32 typedef HANDLE PlatformFile;
29 #elif defined(OS_POSIX) 33 #elif defined(OS_POSIX)
30 typedef int PlatformFile; 34 typedef int PlatformFile;
35
36 #if defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL)
37 typedef struct stat stat_wrapper_t;
38 #else
39 typedef struct stat64 stat_wrapper_t;
31 #endif 40 #endif
32 41 #endif // defined(OS_POSIX)
33 42
34 // Thin wrapper around an OS-level file. 43 // Thin wrapper around an OS-level file.
35 // Note that this class does not provide any support for asynchronous IO, other 44 // Note that this class does not provide any support for asynchronous IO, other
36 // than the ability to create asynchronous handles on Windows. 45 // than the ability to create asynchronous handles on Windows.
37 // 46 //
38 // Note about const: this class does not attempt to determine if the underlying 47 // Note about const: this class does not attempt to determine if the underlying
39 // file system object is affected by a particular method in order to consider 48 // file system object is affected by a particular method in order to consider
40 // that method const or not. Only methods that deal with member variables in an 49 // that method const or not. Only methods that deal with member variables in an
41 // obvious non-modifying way are marked as const. Any method that forward calls 50 // obvious non-modifying way are marked as const. Any method that forward calls
42 // to the OS is not considered const, even if there is no apparent change to 51 // to the OS is not considered const, even if there is no apparent change to
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 }; 122 };
114 123
115 // Used to hold information about a given file. 124 // Used to hold information about a given file.
116 // If you add more fields to this structure (platform-specific fields are OK), 125 // If you add more fields to this structure (platform-specific fields are OK),
117 // make sure to update all functions that use it in file_util_{win|posix}.cc 126 // make sure to update all functions that use it in file_util_{win|posix}.cc
118 // too, and the ParamTraits<base::PlatformFileInfo> implementation in 127 // too, and the ParamTraits<base::PlatformFileInfo> implementation in
119 // chrome/common/common_param_traits.cc. 128 // chrome/common/common_param_traits.cc.
120 struct BASE_EXPORT Info { 129 struct BASE_EXPORT Info {
121 Info(); 130 Info();
122 ~Info(); 131 ~Info();
132 #if defined(OS_POSIX)
133 // Fills this struct with values from |stat_info|.
134 void FromStat(const stat_wrapper_t& stat_info);
135 #endif
123 136
124 // The size of the file in bytes. Undefined when is_directory is true. 137 // The size of the file in bytes. Undefined when is_directory is true.
125 int64 size; 138 int64 size;
126 139
127 // True if the file corresponds to a directory. 140 // True if the file corresponds to a directory.
128 bool is_directory; 141 bool is_directory;
129 142
130 // True if the file corresponds to a symbolic link. 143 // True if the file corresponds to a symbolic link.
131 bool is_symbolic_link; 144 bool is_symbolic_link;
132 145
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 #endif 299 #endif
287 300
288 Error error_details_; 301 Error error_details_;
289 bool created_; 302 bool created_;
290 bool async_; 303 bool async_;
291 }; 304 };
292 305
293 } // namespace base 306 } // namespace base
294 307
295 #endif // BASE_FILES_FILE_H_ 308 #endif // BASE_FILES_FILE_H_
OLDNEW
« no previous file with comments | « base/file_util_posix.cc ('k') | base/files/file_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698