From f4f111b617be50c32d64a6d3b8129a98dc0ccbe1 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Sun, 3 Mar 2024 12:09:42 +0200 Subject: [PATCH] draft redesign of new fs --- CMakeLists.txt | 5 +++++ src/core/file_sys/file_system.cpp | 0 src/core/file_sys/file_system.h | 35 +++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 src/core/file_sys/file_system.cpp create mode 100644 src/core/file_sys/file_system.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 0eb4ca75..362e99cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -229,6 +229,9 @@ set(FILE_FORMAT src/core/file_format/pfs.h src/core/file_format/psf.h ) +set(FILESYSTEM src/core/file_sys/file_system.cpp + src/core/file_sys/file_system.h) + set(UTILITIES src/Util/config.cpp src/Util/config.h ) @@ -240,6 +243,7 @@ qt_add_executable(shadps4 ${CORE} ${CRYPTO} ${FILE_FORMAT} + ${FILESYSTEM} ${UTILITIES} ) else() @@ -308,6 +312,7 @@ add_executable(shadps4 ${CORE} ${CRYPTO} ${FILE_FORMAT} + ${FILESYSTEM} ${UTILITIES} ) endif() diff --git a/src/core/file_sys/file_system.cpp b/src/core/file_sys/file_system.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/core/file_sys/file_system.h b/src/core/file_sys/file_system.h new file mode 100644 index 00000000..23fbdad6 --- /dev/null +++ b/src/core/file_sys/file_system.h @@ -0,0 +1,35 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include +#include +#include + +#include "common/types.h" + +enum FileAccess { + FILEACCESS_NONE = 0, + FILEACCESS_READ = 1, + FILEACCESS_WRITE = 2, +}; + +enum FileMove { FILEMOVE_BEGIN = 0, FILEMOVE_CURRENT = 1, FILEMOVE_END = 2 }; + +class IFileSystem { +public: + virtual ~IFileSystem() {} + + virtual int OpenFile(std::string filename, FileAccess access) = 0; + virtual void CloseFile(u32 handle) = 0; + virtual size_t ReadFile(u32 handle, u8* pointer, s64 size) = 0; + virtual size_t WriteFile(u32 handle, const u8* pointer, s64 size) = 0; + virtual size_t SeekFile(u32 handle, s32 position, FileMove type) = 0; + virtual bool OwnsHandle(u32 handle) = 0; + virtual bool MkDir(const std::string& dirname) = 0; + virtual bool RmDir(const std::string& dirname) = 0; + virtual int RenameFile(const std::string& from, const std::string& to) = 0; + virtual bool RemoveFile(const std::string& filename) = 0; +}; \ No newline at end of file