blob: 00dcb6100b145bfaf7d9ec00852bf85a2e42310a [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
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
18namespace webrtc {
andrew@webrtc.org5ae19de2011-12-13 22:59:33 +000019
niklase@google.com470e71d2011-07-07 08:21:25 +000020class FileWrapperImpl : public FileWrapper
21{
22public:
23 FileWrapperImpl();
24 virtual ~FileWrapperImpl();
25
andrew@webrtc.org5ae19de2011-12-13 22:59:33 +000026 virtual int FileName(char* fileNameUTF8,
27 size_t size) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000028
29 virtual bool Open() const;
30
andrew@webrtc.org5ae19de2011-12-13 22:59:33 +000031 virtual int OpenFile(const char* fileNameUTF8,
32 bool readOnly,
33 bool loop = false,
34 bool text = false);
niklase@google.com470e71d2011-07-07 08:21:25 +000035
andrew@webrtc.org5ae19de2011-12-13 22:59:33 +000036 virtual int CloseFile();
37 virtual int SetMaxFileSize(size_t bytes);
38 virtual int Flush();
niklase@google.com470e71d2011-07-07 08:21:25 +000039
40 virtual int Read(void* buf, int len);
41 virtual bool Write(const void *buf, int len);
andrew@webrtc.org5ae19de2011-12-13 22:59:33 +000042 virtual int WriteText(const char* format, ...);
niklase@google.com470e71d2011-07-07 08:21:25 +000043 virtual int Rewind();
44
niklase@google.com470e71d2011-07-07 08:21:25 +000045private:
andrew@webrtc.org5ae19de2011-12-13 22:59:33 +000046 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.com470e71d2011-07-07 08:21:25 +000053};
andrew@webrtc.org5ae19de2011-12-13 22:59:33 +000054
niklase@google.com470e71d2011-07-07 08:21:25 +000055} // namespace webrtc
56
57#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_FILE_IMPL_H_