niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 14 | #include <stdio.h> |
| 15 | |
phoglund@webrtc.org | 740be44 | 2012-12-12 12:52:15 +0000 | [diff] [blame] | 16 | #include "webrtc/system_wrappers/interface/file_wrapper.h" |
| 17 | #include "webrtc/system_wrappers/interface/scoped_ptr.h" |
henrike@webrtc.org | 9a6dac4 | 2012-09-27 22:20:34 +0000 | [diff] [blame] | 18 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | namespace webrtc { |
andrew@webrtc.org | 5ae19de | 2011-12-13 22:59:33 +0000 | [diff] [blame] | 20 | |
henrike@webrtc.org | 9a6dac4 | 2012-09-27 22:20:34 +0000 | [diff] [blame] | 21 | class RWLockWrapper; |
| 22 | |
phoglund@webrtc.org | 740be44 | 2012-12-12 12:52:15 +0000 | [diff] [blame] | 23 | class FileWrapperImpl : public FileWrapper { |
| 24 | public: |
| 25 | FileWrapperImpl(); |
| 26 | virtual ~FileWrapperImpl(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 27 | |
phoglund@webrtc.org | 740be44 | 2012-12-12 12:52:15 +0000 | [diff] [blame] | 28 | virtual int FileName(char* file_name_utf8, |
| 29 | size_t size) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 30 | |
phoglund@webrtc.org | 740be44 | 2012-12-12 12:52:15 +0000 | [diff] [blame] | 31 | virtual bool Open() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | |
phoglund@webrtc.org | 740be44 | 2012-12-12 12:52:15 +0000 | [diff] [blame] | 33 | virtual int OpenFile(const char* file_name_utf8, |
| 34 | bool read_only, |
| 35 | bool loop = false, |
| 36 | bool text = false); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 37 | |
phoglund@webrtc.org | 740be44 | 2012-12-12 12:52:15 +0000 | [diff] [blame] | 38 | virtual int CloseFile(); |
| 39 | virtual int SetMaxFileSize(size_t bytes); |
| 40 | virtual int Flush(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | |
phoglund@webrtc.org | 740be44 | 2012-12-12 12:52:15 +0000 | [diff] [blame] | 42 | virtual int Read(void* buf, int length); |
| 43 | virtual bool Write(const void* buf, int length); |
| 44 | virtual int WriteText(const char* format, ...); |
| 45 | virtual int Rewind(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 46 | |
phoglund@webrtc.org | 740be44 | 2012-12-12 12:52:15 +0000 | [diff] [blame] | 47 | private: |
| 48 | int CloseFileImpl(); |
| 49 | int FlushImpl(); |
henrike@webrtc.org | 9a6dac4 | 2012-09-27 22:20:34 +0000 | [diff] [blame] | 50 | |
phoglund@webrtc.org | 740be44 | 2012-12-12 12:52:15 +0000 | [diff] [blame] | 51 | scoped_ptr<RWLockWrapper> rw_lock_; |
henrike@webrtc.org | 9a6dac4 | 2012-09-27 22:20:34 +0000 | [diff] [blame] | 52 | |
phoglund@webrtc.org | 740be44 | 2012-12-12 12:52:15 +0000 | [diff] [blame] | 53 | FILE* id_; |
| 54 | bool open_; |
| 55 | bool looping_; |
| 56 | bool read_only_; |
| 57 | size_t max_size_in_bytes_; // -1 indicates file size limitation is off |
| 58 | size_t size_in_bytes_; |
| 59 | char file_name_utf8_[kMaxFileNameSize]; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 60 | }; |
andrew@webrtc.org | 5ae19de | 2011-12-13 22:59:33 +0000 | [diff] [blame] | 61 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 62 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 63 | |
phoglund@webrtc.org | 740be44 | 2012-12-12 12:52:15 +0000 | [diff] [blame] | 64 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_FILE_IMPL_H_ |