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 { 19 class FileWrapperImpl : public FileWrapper 20 { 21 public: 22 FileWrapperImpl(); 23 virtual ~FileWrapperImpl(); 24 25 virtual WebRtc_Word32 FileName(WebRtc_Word8* fileNameUTF8, 26 WebRtc_UWord32 size) const; 27 28 virtual bool Open() const; 29 30 virtual WebRtc_Word32 OpenFile(const WebRtc_Word8* fileNameUTF8, 31 const bool readOnly, 32 const bool loop = false, 33 const bool text = false); 34 35 virtual WebRtc_Word32 CloseFile(); 36 virtual WebRtc_Word32 SetMaxFileSize(WebRtc_Word32 bytes); 37 virtual WebRtc_Word32 Flush(); 38 39 virtual int Read(void* buf, int len); 40 virtual bool Write(const void *buf, int len); 41 virtual int Rewind(); 42 43 virtual WebRtc_Word32 WriteText(const WebRtc_Word8* text, ...); 44 45 private: 46 FILE* _id; 47 bool _open; 48 bool _looping; 49 bool _readOnly; 50 bool _text; 51 WebRtc_Word32 _maxSizeInBytes; // -1 indicates file size limitation is off 52 WebRtc_UWord32 _sizeInBytes; 53 WebRtc_Word8 _fileNameUTF8[kMaxFileNameSize]; 54 }; 55 } // namespace webrtc 56 57 #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_FILE_IMPL_H_ 58