CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Core/FileSystems/BlobFileSystem.h
Views: 1401
1
// Copyright (c) 2017- PPSSPP Project.
2
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.
6
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.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#pragma once
19
20
// This is used for opening a debug file as a blob, and mounting it.
21
// Importantly, uses a fileLoader for all access, so http:// URLs are supported.
22
// As of writing, only used by GE dump replay.
23
24
#include <map>
25
#include <string>
26
27
#include "Common/File/Path.h"
28
#include "Core/Loaders.h"
29
#include "Core/FileSystems/FileSystem.h"
30
31
class BlobFileSystem : public IFileSystem {
32
public:
33
BlobFileSystem(IHandleAllocator *hAlloc, FileLoader *fileLoader, std::string alias);
34
~BlobFileSystem();
35
36
void DoState(PointerWrap &p) override;
37
std::vector<PSPFileInfo> GetDirListing(const std::string &path, bool *exists = nullptr) override;
38
int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override;
39
void CloseFile(u32 handle) override;
40
size_t ReadFile(u32 handle, u8 *pointer, s64 size) override;
41
size_t ReadFile(u32 handle, u8 *pointer, s64 size, int &usec) override;
42
size_t WriteFile(u32 handle, const u8 *pointer, s64 size) override;
43
size_t WriteFile(u32 handle, const u8 *pointer, s64 size, int &usec) override;
44
size_t SeekFile(u32 handle, s32 position, FileMove type) override;
45
PSPFileInfo GetFileInfo(std::string filename) override;
46
bool OwnsHandle(u32 handle) override;
47
int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) override;
48
PSPDevType DevType(u32 handle) override;
49
FileSystemFlags Flags() override { return FileSystemFlags::FLASH; }
50
51
bool MkDir(const std::string &dirname) override;
52
bool RmDir(const std::string &dirname) override;
53
int RenameFile(const std::string &from, const std::string &to) override;
54
bool RemoveFile(const std::string &filename) override;
55
u64 FreeSpace(const std::string &path) override;
56
57
bool ComputeRecursiveDirSizeIfFast(const std::string &path, int64_t *size) override { return false; }
58
59
private:
60
// File positions.
61
std::map<u32, s64> entries_;
62
63
IHandleAllocator *alloc_;
64
FileLoader *fileLoader_;
65
std::string alias_;
66
};
67
68