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

Side by Side Diff: base/file_util.h

Issue 357003: Move the spellchecker to the renderer.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rename Created 11 years, 1 month 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 | « no previous file | base/file_util_posix.cc » ('j') | chrome/browser/spellcheck_host.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 10 matching lines...) Expand all
21 #include <stack> 21 #include <stack>
22 #include <string> 22 #include <string>
23 #include <vector> 23 #include <vector>
24 24
25 #include "base/basictypes.h" 25 #include "base/basictypes.h"
26 #include "base/file_path.h" 26 #include "base/file_path.h"
27 #include "base/scoped_ptr.h" 27 #include "base/scoped_ptr.h"
28 #include "base/string16.h" 28 #include "base/string16.h"
29 #include "base/time.h" 29 #include "base/time.h"
30 30
31 #if defined(OS_POSIX)
32 #include "base/file_descriptor_posix.h"
33 #endif
34
31 namespace base { 35 namespace base {
32 class Time; 36 class Time;
33 } 37 }
34 38
35 namespace file_util { 39 namespace file_util {
36 40
37 //----------------------------------------------------------------------------- 41 //-----------------------------------------------------------------------------
38 // Functions that operate purely on a path string w/o touching the filesystem: 42 // Functions that operate purely on a path string w/o touching the filesystem:
39 43
40 // Returns true if the given path ends with a path separator character. 44 // Returns true if the given path ends with a path separator character.
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 // The default constructor sets all members to invalid/null values. 483 // The default constructor sets all members to invalid/null values.
480 MemoryMappedFile(); 484 MemoryMappedFile();
481 ~MemoryMappedFile(); 485 ~MemoryMappedFile();
482 486
483 // Opens an existing file and maps it into memory. Access is restricted to 487 // Opens an existing file and maps it into memory. Access is restricted to
484 // read only. If this object already points to a valid memory mapped file 488 // read only. If this object already points to a valid memory mapped file
485 // then this method will fail and return false. If it cannot open the file, 489 // then this method will fail and return false. If it cannot open the file,
486 // the file does not exist, or the memory mapping fails, it will return false. 490 // the file does not exist, or the memory mapping fails, it will return false.
487 // Later we may want to allow the user to specify access. 491 // Later we may want to allow the user to specify access.
488 bool Initialize(const FilePath& file_name); 492 bool Initialize(const FilePath& file_name);
493 #if defined(OS_POSIX)
494 // As above, but works with an alreay-opened file.
495 bool Initialize(const base::FileDescriptor& fd);
496 #endif
489 497
490 const uint8* data() const { return data_; } 498 const uint8* data() const { return data_; }
491 size_t length() const { return length_; } 499 size_t length() const { return length_; }
492 500
493 // Is file_ a valid file handle that points to an open, memory mapped file? 501 // Is file_ a valid file handle that points to an open, memory mapped file?
494 bool IsValid(); 502 bool IsValid();
495 503
496 private: 504 private:
497 // Map the file to memory, set data_ to that memory address. Return true on 505 // Map the file to memory, set data_ to that memory address. Return true on
498 // success, false on any kind of failure. This is a helper for Initialize(). 506 // success, false on any kind of failure. This is a helper for Initialize().
499 bool MapFileToMemory(const FilePath& file_name); 507 bool MapFileToMemory(const FilePath& file_name);
500 508
509 #if defined(OS_POSIX)
510 bool MapFileToMemoryInternal();
511 #endif
512
501 // Closes all open handles. Later we may want to make this public. 513 // Closes all open handles. Later we may want to make this public.
502 void CloseHandles(); 514 void CloseHandles();
503 515
504 #if defined(OS_WIN) 516 #if defined(OS_WIN)
505 HANDLE file_; 517 HANDLE file_;
506 HANDLE file_mapping_; 518 HANDLE file_mapping_;
507 #elif defined(OS_POSIX) 519 #elif defined(OS_POSIX)
508 // The file descriptor. 520 // The file descriptor.
509 int file_; 521 base::FileDescriptor file_;
510 #endif 522 #endif
511 uint8* data_; 523 uint8* data_;
512 size_t length_; 524 size_t length_;
513 525
514 DISALLOW_COPY_AND_ASSIGN(MemoryMappedFile); 526 DISALLOW_COPY_AND_ASSIGN(MemoryMappedFile);
515 }; 527 };
516 528
517 // Renames a file using the SHFileOperation API to ensure that the target file 529 // Renames a file using the SHFileOperation API to ensure that the target file
518 // gets the correct default security descriptor in the new path. 530 // gets the correct default security descriptor in the new path.
519 bool RenameFileAndResetSecurityDescriptor( 531 bool RenameFileAndResetSecurityDescriptor(
520 const FilePath& source_file_path, 532 const FilePath& source_file_path,
521 const FilePath& target_file_path); 533 const FilePath& target_file_path);
522 534
523 } // namespace file_util 535 } // namespace file_util
524 536
525 #endif // BASE_FILE_UTIL_H_ 537 #endif // BASE_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | base/file_util_posix.cc » ('j') | chrome/browser/spellcheck_host.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698