ScummVM API documentation
stdiostream.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef BACKENDS_FS_STDIOSTREAM_H
23 #define BACKENDS_FS_STDIOSTREAM_H
24 
25 #include "common/scummsys.h"
26 #include "common/noncopyable.h"
27 #include "common/stream.h"
28 #include "common/str.h"
29 
31 public:
32  enum WriteMode {
33  WriteMode_Read = 0,
34  WriteMode_Write = 1,
35  WriteMode_WriteAtomic = 2,
36  };
37 
38 protected:
40  void *_handle;
41  Common::String *_path;
42 
43  static StdioStream *makeFromPathHelper(const Common::String &path, WriteMode writeMode,
44  StdioStream *(*factory)(void *handle));
45 
46 public:
51  static StdioStream *makeFromPath(const Common::String &path, WriteMode writeMode) {
52  return makeFromPathHelper(path, writeMode, [](void *handle) {
53  return new StdioStream(handle);
54  });
55  }
56 
57  StdioStream(void *handle);
58  ~StdioStream() override;
59 
60  bool err() const override;
61  void clearErr() override;
62  bool eos() const override;
63 
64  uint32 write(const void *dataPtr, uint32 dataSize) override;
65  bool flush() override;
66 
67  int64 pos() const override;
68  int64 size() const override;
69  bool seek(int64 offs, int whence = SEEK_SET) override;
70  uint32 read(void *dataPtr, uint32 dataSize) override;
71 
81  bool setBufferSize(uint32 bufferSize);
82 
83 private:
95  bool moveFile(const Common::String &src, const Common::String &dst);
96 };
97 
98 #endif
Definition: str.h:59
void clearErr() override
int64 pos() const override
bool flush() override
uint32 read(void *dataPtr, uint32 dataSize) override
bool seek(int64 offs, int whence=SEEK_SET) override
Definition: stream.h:745
bool err() const override
Definition: noncopyable.h:39
bool eos() const override
Definition: stdiostream.h:30
void * _handle
Definition: stdiostream.h:40
bool setBufferSize(uint32 bufferSize)
uint32 write(const void *dataPtr, uint32 dataSize) override
Definition: stream.h:351
static StdioStream * makeFromPath(const Common::String &path, WriteMode writeMode)
Definition: stdiostream.h:51
int64 size() const override