OLD | NEW |
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 29 matching lines...) Expand all Loading... |
40 | 40 |
41 // Open and Create give files with both reading and writing enabled. | 41 // Open and Create give files with both reading and writing enabled. |
42 static File Open(const std::string& path); | 42 static File Open(const std::string& path); |
43 static File Open(Pathname&& path); | 43 static File Open(Pathname&& path); |
44 static File Open(const Pathname& path); | 44 static File Open(const Pathname& path); |
45 // If the file already exists it will be overwritten. | 45 // If the file already exists it will be overwritten. |
46 static File Create(const std::string& path); | 46 static File Create(const std::string& path); |
47 static File Create(Pathname&& path); | 47 static File Create(Pathname&& path); |
48 static File Create(const Pathname& path); | 48 static File Create(const Pathname& path); |
49 | 49 |
| 50 // Remove a file in the file system. |
| 51 static bool Remove(const std::string& path); |
| 52 static bool Remove(Pathname&& path); |
| 53 static bool Remove(const Pathname& path); |
| 54 |
50 size_t Write(const uint8_t* data, size_t length); | 55 size_t Write(const uint8_t* data, size_t length); |
51 size_t Read(uint8_t* buffer, size_t length); | 56 size_t Read(uint8_t* buffer, size_t length); |
52 | 57 |
53 // The current position in the file after a call to these methods is platform | 58 // The current position in the file after a call to these methods is platform |
54 // dependent (MSVC gives position offset+length, most other | 59 // dependent (MSVC gives position offset+length, most other |
55 // compilers/platforms do not alter the position), i.e. do not depend on it, | 60 // compilers/platforms do not alter the position), i.e. do not depend on it, |
56 // do a Seek before any subsequent Read/Write. | 61 // do a Seek before any subsequent Read/Write. |
57 size_t WriteAt(const uint8_t* data, size_t length, size_t offset); | 62 size_t WriteAt(const uint8_t* data, size_t length, size_t offset); |
58 size_t ReadAt(uint8_t* buffer, size_t length, size_t offset); | 63 size_t ReadAt(uint8_t* buffer, size_t length, size_t offset); |
59 | 64 |
60 // Attempt to position the file at the given offset from the start. | 65 // Attempt to position the file at the given offset from the start. |
61 // Returns true if successful, false otherwise. | 66 // Returns true if successful, false otherwise. |
62 bool Seek(size_t offset); | 67 bool Seek(size_t offset); |
63 | 68 |
64 // Attempt to close the file. Returns true if successful, false otherwise, | 69 // Attempt to close the file. Returns true if successful, false otherwise, |
65 // most notably when the file is already closed. | 70 // most notably when the file is already closed. |
66 bool Close(); | 71 bool Close(); |
67 | 72 |
68 bool IsOpen(); | 73 bool IsOpen(); |
69 | 74 |
70 private: | 75 private: |
71 PlatformFile file_; | 76 PlatformFile file_; |
72 RTC_DISALLOW_COPY_AND_ASSIGN(File); | 77 RTC_DISALLOW_COPY_AND_ASSIGN(File); |
73 }; | 78 }; |
74 | 79 |
75 } // namespace rtc | 80 } // namespace rtc |
76 | 81 |
77 #endif // WEBRTC_BASE_FILE_H_ | 82 #endif // WEBRTC_BASE_FILE_H_ |
OLD | NEW |