OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_FILE_IMPL_H_ | |
12 #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_FILE_IMPL_H_ | |
13 | |
14 #include <stdio.h> | |
15 | |
16 #include <memory> | |
17 | |
18 #include "webrtc/system_wrappers/include/file_wrapper.h" | |
19 | |
20 namespace webrtc { | |
21 | |
22 class RWLockWrapper; | |
23 | |
24 class FileWrapperImpl : public FileWrapper { | |
25 public: | |
26 FileWrapperImpl(); | |
27 ~FileWrapperImpl() override; | |
28 | |
29 int FileName(char* file_name_utf8, size_t size) const override; | |
30 | |
31 bool Open() const override; | |
32 | |
33 int OpenFile(const char* file_name_utf8, | |
34 bool read_only, | |
35 bool loop = false, | |
36 bool text = false) override; | |
37 | |
38 int OpenFromFileHandle(FILE* handle, | |
39 bool manage_file, | |
40 bool read_only, | |
41 bool loop = false) override; | |
42 | |
43 int CloseFile() override; | |
44 int SetMaxFileSize(size_t bytes) override; | |
45 int Flush() override; | |
46 | |
47 int Read(void* buf, size_t length) override; | |
48 bool Write(const void* buf, size_t length) override; | |
49 int WriteText(const char* format, ...) override; | |
50 int Rewind() override; | |
51 | |
52 private: | |
53 int CloseFileImpl(); | |
54 int FlushImpl(); | |
55 | |
56 std::unique_ptr<RWLockWrapper> rw_lock_; | |
57 | |
58 FILE* id_; | |
59 bool managed_file_handle_; | |
60 bool open_; | |
61 bool looping_; | |
62 bool read_only_; | |
63 size_t max_size_in_bytes_; // -1 indicates file size limitation is off | |
64 size_t size_in_bytes_; | |
65 char file_name_utf8_[kMaxFileNameSize]; | |
66 }; | |
67 | |
68 } // namespace webrtc | |
69 | |
70 #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_FILE_IMPL_H_ | |
OLD | NEW |