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