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