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

Side by Side Diff: base/file_util.h

Issue 6005: Cross-platform equivalent of fopen, _wfopen_s etc.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 2 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // This file contains utility functions for dealing with the local 5 // This file contains utility functions for dealing with the local
6 // filesystem. 6 // filesystem.
7 7
8 #ifndef BASE_FILE_UTIL_H_ 8 #ifndef BASE_FILE_UTIL_H_
9 #define BASE_FILE_UTIL_H_ 9 #define BASE_FILE_UTIL_H_
10 10
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 12
13 #if defined(OS_WIN) 13 #if defined(OS_WIN)
14 #include <windows.h> 14 #include <windows.h>
15 #elif defined(OS_POSIX) 15 #elif defined(OS_POSIX)
16 #include <fts.h> 16 #include <fts.h>
17 #endif 17 #endif
18 18
19 #include <stdio.h>
20
19 #include <stack> 21 #include <stack>
20 #include <string> 22 #include <string>
21 #include <vector> 23 #include <vector>
22 24
23 #include "base/basictypes.h" 25 #include "base/basictypes.h"
24 26
25 namespace file_util { 27 namespace file_util {
26 28
27 //----------------------------------------------------------------------------- 29 //-----------------------------------------------------------------------------
28 // Constants 30 // Constants
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 241
240 // True if the file corresponds to a directory. 242 // True if the file corresponds to a directory.
241 bool is_directory; 243 bool is_directory;
242 244
243 // Add additional fields here as needed. 245 // Add additional fields here as needed.
244 }; 246 };
245 247
246 // Returns information about the given file path. 248 // Returns information about the given file path.
247 bool GetFileInfo(const std::wstring& file_path, FileInfo* info); 249 bool GetFileInfo(const std::wstring& file_path, FileInfo* info);
248 250
251 // Wrapper for fopen-like calls. Returns non-NULL FILE* on success.
252 FILE* OpenFile(const std::string& filename, const char* mode);
253 FILE* OpenFile(const std::wstring& filename, const char* mode);
254
255 // Closes file opened by OpenFile. Returns true on success.
256 bool CloseFile(FILE* file);
257
249 // Reads the given number of bytes from the file into the buffer. Returns 258 // Reads the given number of bytes from the file into the buffer. Returns
250 // the number of read bytes, or -1 on error. 259 // the number of read bytes, or -1 on error.
251 int ReadFile(const std::wstring& filename, char* data, int size); 260 int ReadFile(const std::wstring& filename, char* data, int size);
252 261
253 // Writes the given buffer into the file, overwriting any data that was 262 // Writes the given buffer into the file, overwriting any data that was
254 // previously there. Returns the number of bytes written, or -1 on error. 263 // previously there. Returns the number of bytes written, or -1 on error.
255 int WriteFile(const std::wstring& filename, const char* data, int size); 264 int WriteFile(const std::wstring& filename, const char* data, int size);
256 265
257 // Gets the current working directory for the process. 266 // Gets the current working directory for the process.
258 bool GetCurrentDirectory(std::wstring* path); 267 bool GetCurrentDirectory(std::wstring* path);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 340
332 // Renames a file using the MoveFileEx API and ensures that the target file gets 341 // Renames a file using the MoveFileEx API and ensures that the target file gets
333 // the correct security descriptor in the new path. 342 // the correct security descriptor in the new path.
334 bool RenameFileAndResetSecurityDescriptor( 343 bool RenameFileAndResetSecurityDescriptor(
335 const std::wstring& source_file_path, 344 const std::wstring& source_file_path,
336 const std::wstring& target_file_path); 345 const std::wstring& target_file_path);
337 346
338 } // namespace file_util 347 } // namespace file_util
339 348
340 #endif // BASE_FILE_UTIL_H_ 349 #endif // BASE_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « base/event_recorder.cc ('k') | base/file_util.cc » ('j') | base/file_util_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698