ScummVM API documentation
psp-stream.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 PSPSTREAM_H_
23 #define PSPSTREAM_H_
24 
25 #include <pspkerneltypes.h>
26 #include "backends/platform/psp/powerman.h"
27 //#include "common/list.h"
28 #include "common/noncopyable.h"
29 #include "common/stream.h"
30 #include "common/str.h"
31 
36 protected:
37  SceUID _handle; // file handle
38  Common::String _path;
39  int _fileSize;
40  bool _writeMode; // for resuming in the right mode
41  int _physicalPos; // physical position in file
42  int _pos; // position. Sometimes virtual
43  bool _eos; // EOS flag
44 
45  enum {
46  SuspendError = 2,
47  ResumeError = 3
48  };
49 
50  // debug stuff
51  mutable int _error; // file error state
52  int _errorSuspend; // for debugging
53  mutable int _errorSource;
54  int _errorPos;
55  SceUID _errorHandle;
56  int _suspendCount;
57 
58  bool physicalSeekFromCur(int32 offset);
59 
60 public:
61 
66  static PspIoStream *makeFromPath(const Common::String &path, bool writeMode);
67 
68  PspIoStream(const Common::String &path, bool writeMode);
69  ~PspIoStream() override;
70 
71  SceUID open(); // open the file pointed to by the file path
72 
73  bool err() const override;
74  void clearErr() override;
75  bool eos() const override;
76 
77  uint32 write(const void *dataPtr, uint32 dataSize) override;
78  bool flush() override;
79 
80  int64 pos() const override;
81  int64 size() const override;
82  bool seek(int64 offs, int whence = SEEK_SET) override;
83  uint32 read(void *dataPtr, uint32 dataSize) override;
84 
85  // for suspending
86  int suspend() override; /* Suspendable interface (power manager) */
87  int resume() override; /* " " */
88 };
89 
90 #endif /* PSPSTREAM_H_ */
Definition: str.h:59
int64 pos() const override
uint32 read(void *dataPtr, uint32 dataSize) override
Definition: powerman.h:35
static PspIoStream * makeFromPath(const Common::String &path, bool writeMode)
bool flush() override
void clearErr() override
bool seek(int64 offs, int whence=SEEK_SET) override
Definition: stream.h:745
Definition: noncopyable.h:39
uint32 write(const void *dataPtr, uint32 dataSize) override
bool err() const override
bool eos() const override
Definition: stream.h:351
Definition: psp-stream.h:35
int64 size() const override