summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/CMakeLists.txt3
-rw-r--r--src/core/file_sys/archive.h20
-rw-r--r--src/core/file_sys/archive_romfs.cpp11
-rw-r--r--src/core/file_sys/archive_romfs.h8
-rw-r--r--src/core/file_sys/file.h53
-rw-r--r--src/core/file_sys/file_romfs.cpp59
-rw-r--r--src/core/file_sys/file_romfs.h54
7 files changed, 208 insertions, 0 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 1f358ec8d..14c114b63 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -23,6 +23,7 @@ set(SRCS
23 arm/interpreter/armvirt.cpp 23 arm/interpreter/armvirt.cpp
24 arm/interpreter/thumbemu.cpp 24 arm/interpreter/thumbemu.cpp
25 file_sys/archive_romfs.cpp 25 file_sys/archive_romfs.cpp
26 file_sys/file_romfs.cpp
26 hle/kernel/address_arbiter.cpp 27 hle/kernel/address_arbiter.cpp
27 hle/kernel/archive.cpp 28 hle/kernel/archive.cpp
28 hle/kernel/event.cpp 29 hle/kernel/event.cpp
@@ -77,6 +78,8 @@ set(HEADERS
77 arm/arm_interface.h 78 arm/arm_interface.h
78 file_sys/archive.h 79 file_sys/archive.h
79 file_sys/archive_romfs.h 80 file_sys/archive_romfs.h
81 file_sys/file.h
82 file_sys/file_romfs.h
80 hle/kernel/address_arbiter.h 83 hle/kernel/address_arbiter.h
81 hle/kernel/archive.h 84 hle/kernel/archive.h
82 hle/kernel/event.h 85 hle/kernel/event.h
diff --git a/src/core/file_sys/archive.h b/src/core/file_sys/archive.h
index ac5630bea..67440ef58 100644
--- a/src/core/file_sys/archive.h
+++ b/src/core/file_sys/archive.h
@@ -4,7 +4,12 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <memory>
8
7#include "common/common_types.h" 9#include "common/common_types.h"
10#include "common/bit_field.h"
11
12#include "core/file_sys/file.h"
8 13
9#include "core/hle/kernel/kernel.h" 14#include "core/hle/kernel/kernel.h"
10 15
@@ -13,6 +18,13 @@
13 18
14namespace FileSys { 19namespace FileSys {
15 20
21union Mode {
22 u32 hex;
23 BitField<0, 1, u32> read_flag;
24 BitField<1, 1, u32> write_flag;
25 BitField<2, 1, u32> create_flag;
26};
27
16class Archive : NonCopyable { 28class Archive : NonCopyable {
17public: 29public:
18 /// Supported archive types 30 /// Supported archive types
@@ -36,6 +48,14 @@ public:
36 virtual IdCode GetIdCode() const = 0; 48 virtual IdCode GetIdCode() const = 0;
37 49
38 /** 50 /**
51 * Open a file specified by its path, using the specified mode
52 * @param path Path relative to the archive
53 * @param mode Mode to open the file with
54 * @return Opened file, or nullptr
55 */
56 virtual std::unique_ptr<File> OpenFile(const std::string& path, const Mode mode) const = 0;
57
58 /**
39 * Read data from the archive 59 * Read data from the archive
40 * @param offset Offset in bytes to start reading data from 60 * @param offset Offset in bytes to start reading data from
41 * @param length Length in bytes of data to read from archive 61 * @param length Length in bytes of data to read from archive
diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp
index dc3fb1807..99ded4d8b 100644
--- a/src/core/file_sys/archive_romfs.cpp
+++ b/src/core/file_sys/archive_romfs.cpp
@@ -5,6 +5,7 @@
5#include "common/common_types.h" 5#include "common/common_types.h"
6 6
7#include "core/file_sys/archive_romfs.h" 7#include "core/file_sys/archive_romfs.h"
8#include "core/file_sys/file_romfs.h"
8 9
9//////////////////////////////////////////////////////////////////////////////////////////////////// 10////////////////////////////////////////////////////////////////////////////////////////////////////
10// FileSys namespace 11// FileSys namespace
@@ -22,6 +23,16 @@ Archive_RomFS::~Archive_RomFS() {
22} 23}
23 24
24/** 25/**
26 * Open a file specified by its path, using the specified mode
27 * @param path Path relative to the archive
28 * @param mode Mode to open the file with
29 * @return Opened file, or nullptr
30 */
31std::unique_ptr<File> Archive_RomFS::OpenFile(const std::string& path, const Mode mode) const {
32 return std::unique_ptr<File>(new File_RomFS);
33}
34
35/**
25 * Read data from the archive 36 * Read data from the archive
26 * @param offset Offset in bytes to start reading data from 37 * @param offset Offset in bytes to start reading data from
27 * @param length Length in bytes of data to read from archive 38 * @param length Length in bytes of data to read from archive
diff --git a/src/core/file_sys/archive_romfs.h b/src/core/file_sys/archive_romfs.h
index e9ed6f77a..a7669dd71 100644
--- a/src/core/file_sys/archive_romfs.h
+++ b/src/core/file_sys/archive_romfs.h
@@ -29,6 +29,14 @@ public:
29 IdCode GetIdCode() const override { return IdCode::RomFS; }; 29 IdCode GetIdCode() const override { return IdCode::RomFS; };
30 30
31 /** 31 /**
32 * Open a file specified by its path, using the specified mode
33 * @param path Path relative to the archive
34 * @param mode Mode to open the file with
35 * @return Opened file, or nullptr
36 */
37 std::unique_ptr<File> OpenFile(const std::string& path, const Mode mode) const override;
38
39 /**
32 * Read data from the archive 40 * Read data from the archive
33 * @param offset Offset in bytes to start reading data from 41 * @param offset Offset in bytes to start reading data from
34 * @param length Length in bytes of data to read from archive 42 * @param length Length in bytes of data to read from archive
diff --git a/src/core/file_sys/file.h b/src/core/file_sys/file.h
new file mode 100644
index 000000000..f7b009f5a
--- /dev/null
+++ b/src/core/file_sys/file.h
@@ -0,0 +1,53 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "common/common_types.h"
8
9#include "core/hle/kernel/kernel.h"
10
11////////////////////////////////////////////////////////////////////////////////////////////////////
12// FileSys namespace
13
14namespace FileSys {
15
16class File : NonCopyable {
17public:
18 File() { }
19 virtual ~File() { }
20
21 /**
22 * Read data from the file
23 * @param offset Offset in bytes to start reading data from
24 * @param length Length in bytes of data to read from file
25 * @param buffer Buffer to read data into
26 * @return Number of bytes read
27 */
28 virtual size_t Read(const u64 offset, const u32 length, u8* buffer) const = 0;
29
30 /**
31 * Write data to the file
32 * @param offset Offset in bytes to start writing data to
33 * @param length Length in bytes of data to write to file
34 * @param buffer Buffer to write data from
35 * @param flush The flush parameters (0 == do not flush)
36 * @return Number of bytes written
37 */
38 virtual size_t Write(const u64 offset, const u32 length, const u32 flush, const u8* buffer) const = 0;
39
40 /**
41 * Get the size of the file in bytes
42 * @return Size of the file in bytes
43 */
44 virtual size_t GetSize() const = 0;
45
46 /**
47 * Close the file
48 * @return true if the file closed correctly
49 */
50 virtual bool Close() const = 0;
51};
52
53} // namespace FileSys
diff --git a/src/core/file_sys/file_romfs.cpp b/src/core/file_sys/file_romfs.cpp
new file mode 100644
index 000000000..00f3c2ea8
--- /dev/null
+++ b/src/core/file_sys/file_romfs.cpp
@@ -0,0 +1,59 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#include "common/common_types.h"
6
7#include "core/file_sys/file_romfs.h"
8
9////////////////////////////////////////////////////////////////////////////////////////////////////
10// FileSys namespace
11
12namespace FileSys {
13
14File_RomFS::File_RomFS() {
15}
16
17File_RomFS::~File_RomFS() {
18}
19
20/**
21 * Read data from the file
22 * @param offset Offset in bytes to start reading data from
23 * @param length Length in bytes of data to read from file
24 * @param buffer Buffer to read data into
25 * @return Number of bytes read
26 */
27size_t File_RomFS::Read(const u64 offset, const u32 length, u8* buffer) const {
28 return -1;
29}
30
31/**
32 * Write data to the file
33 * @param offset Offset in bytes to start writing data to
34 * @param length Length in bytes of data to write to file
35 * @param buffer Buffer to write data from
36 * @param flush The flush parameters (0 == do not flush)
37 * @return Number of bytes written
38 */
39size_t File_RomFS::Write(const u64 offset, const u32 length, const u32 flush, const u8* buffer) const {
40 return -1;
41}
42
43/**
44 * Get the size of the file in bytes
45 * @return Size of the file in bytes
46 */
47size_t File_RomFS::GetSize() const {
48 return -1;
49}
50
51/**
52 * Close the file
53 * @return true if the file closed correctly
54 */
55bool File_RomFS::Close() const {
56 return false;
57}
58
59} // namespace FileSys
diff --git a/src/core/file_sys/file_romfs.h b/src/core/file_sys/file_romfs.h
new file mode 100644
index 000000000..5db43d4a0
--- /dev/null
+++ b/src/core/file_sys/file_romfs.h
@@ -0,0 +1,54 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "common/common_types.h"
8
9#include "core/file_sys/file.h"
10#include "core/loader/loader.h"
11
12////////////////////////////////////////////////////////////////////////////////////////////////////
13// FileSys namespace
14
15namespace FileSys {
16
17class File_RomFS final : public File {
18public:
19 File_RomFS();
20 ~File_RomFS() override;
21
22 /**
23 * Read data from the file
24 * @param offset Offset in bytes to start reading data from
25 * @param length Length in bytes of data to read from file
26 * @param buffer Buffer to read data into
27 * @return Number of bytes read
28 */
29 size_t Read(const u64 offset, const u32 length, u8* buffer) const override;
30
31 /**
32 * Write data to the file
33 * @param offset Offset in bytes to start writing data to
34 * @param length Length in bytes of data to write to file
35 * @param buffer Buffer to write data from
36 * @param flush The flush parameters (0 == do not flush)
37 * @return Number of bytes written
38 */
39 size_t Write(const u64 offset, const u32 length, const u32 flush, const u8* buffer) const override;
40
41 /**
42 * Get the size of the file in bytes
43 * @return Size of the file in bytes
44 */
45 size_t GetSize() const override;
46
47 /**
48 * Close the file
49 * @return true if the file closed correctly
50 */
51 bool Close() const override;
52};
53
54} // namespace FileSys