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

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

Issue 2347473003: Removing, opening and creating files in platform_file and file (Closed)
Patch Set: Comments Created 4 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
« no previous file with comments | « no previous file | webrtc/base/file.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 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 17 matching lines...) Expand all
28 class File { 28 class File {
29 public: 29 public:
30 // Wraps the given PlatformFile. This class is then responsible for closing 30 // Wraps the given PlatformFile. This class is then responsible for closing
31 // the file, which will be done in the destructor if Close is never called. 31 // the file, which will be done in the destructor if Close is never called.
32 explicit File(PlatformFile); 32 explicit File(PlatformFile);
33 ~File(); 33 ~File();
34 34
35 File(File&& other); 35 File(File&& other);
36 File& operator=(File&& other); 36 File& operator=(File&& other);
37 37
38 // Open and Create give files with both reading and writing enabled.
38 static File Open(const std::string& path); 39 static File Open(const std::string& path);
40 // If the file already exists it will be overwritten.
41 static File Create(const std::string& path);
39 42
40 size_t Write(const uint8_t* data, size_t length); 43 size_t Write(const uint8_t* data, size_t length);
41 size_t Read(uint8_t* buffer, size_t length); 44 size_t Read(uint8_t* buffer, size_t length);
42 45
43 // The current position in the file after a call to these methods is platform 46 // The current position in the file after a call to these methods is platform
44 // dependent (MSVC gives position offset+length, most other 47 // dependent (MSVC gives position offset+length, most other
45 // compilers/platforms do not alter the position), i.e. do not depend on it, 48 // compilers/platforms do not alter the position), i.e. do not depend on it,
46 // do a Seek before any subsequent Read/Write. 49 // do a Seek before any subsequent Read/Write.
47 size_t WriteAt(const uint8_t* data, size_t length, size_t offset); 50 size_t WriteAt(const uint8_t* data, size_t length, size_t offset);
48 size_t ReadAt(uint8_t* buffer, size_t length, size_t offset); 51 size_t ReadAt(uint8_t* buffer, size_t length, size_t offset);
49 52
50 // Attempt to position the file at the given offset from the start. 53 // Attempt to position the file at the given offset from the start.
51 // Returns true if successful, false otherwise. 54 // Returns true if successful, false otherwise.
52 bool Seek(size_t offset); 55 bool Seek(size_t offset);
53 56
54 // Attempt to close the file. Returns true if successful, false otherwise, 57 // Attempt to close the file. Returns true if successful, false otherwise,
55 // most notably when the file is already closed. 58 // most notably when the file is already closed.
56 bool Close(); 59 bool Close();
57 60
58 bool IsOpen(); 61 bool IsOpen();
59 62
60 private: 63 private:
61 PlatformFile file_; 64 PlatformFile file_;
62 RTC_DISALLOW_COPY_AND_ASSIGN(File); 65 RTC_DISALLOW_COPY_AND_ASSIGN(File);
63 }; 66 };
64 67
65 } // namespace rtc 68 } // namespace rtc
66 69
67 #endif // WEBRTC_BASE_FILE_H_ 70 #endif // WEBRTC_BASE_FILE_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698