1 // Copyright (c) 2012- PPSSPP Project.
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0 or later versions.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 2.0 for more details.
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
15 // Official git repository and contact information can be found at
16 // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
22 enum IdentifiedFileType
{
25 FILETYPE_PSP_PBP_DIRECTORY
,
32 FILETYPE_PSP_DISC_DIRECTORY
,
37 // Try to reduce support emails...
44 FILETYPE_NORMAL_DIRECTORY
,
46 FILETYPE_PSP_SAVEDATA_DIRECTORY
,
47 FILETYPE_PPSSPP_SAVESTATE
,
54 virtual ~FileLoader() {}
56 virtual bool Exists() = 0;
57 virtual bool IsDirectory() = 0;
58 virtual s64
FileSize() = 0;
59 virtual std::string
Path() const = 0;
60 virtual std::string
Extension() {
61 const std::string filename
= Path();
62 size_t pos
= filename
.find_last_of('.');
63 if (pos
== filename
.npos
) {
66 return filename
.substr(pos
);
70 virtual void Seek(s64 absolutePos
) = 0;
71 virtual size_t Read(size_t bytes
, size_t count
, void *data
) = 0;
72 virtual size_t Read(size_t bytes
, void *data
) {
73 return Read(1, bytes
, data
);
75 virtual size_t ReadAt(s64 absolutePos
, size_t bytes
, size_t count
, void *data
) = 0;
76 virtual size_t ReadAt(s64 absolutePos
, size_t bytes
, void *data
) {
77 return ReadAt(absolutePos
, 1, bytes
, data
);
81 FileLoader
*ConstructFileLoader(const std::string
&filename
);
83 // This can modify the string, for example for stripping off the "/EBOOT.PBP"
84 // for a FILETYPE_PSP_PBP_DIRECTORY.
85 IdentifiedFileType
Identify_File(FileLoader
*fileLoader
);
87 // Can modify the string filename, as it calls IdentifyFile above.
88 bool LoadFile(FileLoader
**fileLoaderPtr
, std::string
*error_string
);