summaryrefslogtreecommitdiff
path: root/src/core/file_sys
diff options
context:
space:
mode:
authorGravatar Subv2018-03-04 14:34:48 -0500
committerGravatar Subv2018-03-04 14:34:48 -0500
commit84e1c0a43016e4c0e99aa50b1486af53b7d05513 (patch)
tree27d2518fb50ce2a48204a3cb715b5a93f5c95ede /src/core/file_sys
parentFS: Stubbed CreateSaveData. It currently does nothing. (diff)
downloadyuzu-84e1c0a43016e4c0e99aa50b1486af53b7d05513.tar.gz
yuzu-84e1c0a43016e4c0e99aa50b1486af53b7d05513.tar.xz
yuzu-84e1c0a43016e4c0e99aa50b1486af53b7d05513.zip
FS: Use the correct error code when trying to open files that don't exist.
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/disk_filesystem.cpp7
-rw-r--r--src/core/file_sys/errors.h25
2 files changed, 6 insertions, 26 deletions
diff --git a/src/core/file_sys/disk_filesystem.cpp b/src/core/file_sys/disk_filesystem.cpp
index be7574fdb..22b17ba04 100644
--- a/src/core/file_sys/disk_filesystem.cpp
+++ b/src/core/file_sys/disk_filesystem.cpp
@@ -7,6 +7,7 @@
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/logging/log.h" 8#include "common/logging/log.h"
9#include "core/file_sys/disk_filesystem.h" 9#include "core/file_sys/disk_filesystem.h"
10#include "core/file_sys/errors.h"
10 11
11namespace FileSys { 12namespace FileSys {
12 13
@@ -22,8 +23,7 @@ ResultVal<std::unique_ptr<StorageBackend>> Disk_FileSystem::OpenFile(const std::
22 auto file = std::make_shared<FileUtil::IOFile>(full_path, mode == Mode::Read ? "rb" : "wb"); 23 auto file = std::make_shared<FileUtil::IOFile>(full_path, mode == Mode::Read ? "rb" : "wb");
23 24
24 if (!file->IsOpen()) { 25 if (!file->IsOpen()) {
25 // TODO(Subv): Find out the correct error code. 26 return ERROR_PATH_NOT_FOUND;
26 return ResultCode(-1);
27 } 27 }
28 28
29 return MakeResult<std::unique_ptr<StorageBackend>>( 29 return MakeResult<std::unique_ptr<StorageBackend>>(
@@ -100,8 +100,7 @@ u64 Disk_FileSystem::GetFreeSpaceSize() const {
100ResultVal<FileSys::EntryType> Disk_FileSystem::GetEntryType(const std::string& path) const { 100ResultVal<FileSys::EntryType> Disk_FileSystem::GetEntryType(const std::string& path) const {
101 std::string full_path = base_directory + path; 101 std::string full_path = base_directory + path;
102 if (!FileUtil::Exists(full_path)) { 102 if (!FileUtil::Exists(full_path)) {
103 // TODO(Subv): Find out what this actually means 103 return ERROR_PATH_NOT_FOUND;
104 return ResultCode(ErrorModule::FS, 1);
105 } 104 }
106 105
107 // TODO(Subv): Find out the EntryType values 106 // TODO(Subv): Find out the EntryType values
diff --git a/src/core/file_sys/errors.h b/src/core/file_sys/errors.h
index be3224ef8..0ed7d2a0c 100644
--- a/src/core/file_sys/errors.h
+++ b/src/core/file_sys/errors.h
@@ -10,36 +10,17 @@ namespace FileSys {
10 10
11namespace ErrCodes { 11namespace ErrCodes {
12enum { 12enum {
13 RomFSNotFound = 100, 13 NotFound = 1,
14 ArchiveNotMounted = 101,
15 FileNotFound = 112,
16 PathNotFound = 113,
17 GameCardNotInserted = 141,
18 NotFound = 120,
19 FileAlreadyExists = 180,
20 DirectoryAlreadyExists = 185,
21 AlreadyExists = 190,
22 InvalidOpenFlags = 230,
23 DirectoryNotEmpty = 240,
24 NotAFile = 250,
25 NotFormatted = 340, ///< This is used by the FS service when creating a SaveData archive
26 ExeFSSectionNotFound = 567,
27 CommandNotAllowed = 630,
28 InvalidReadFlag = 700,
29 InvalidPath = 702,
30 WriteBeyondEnd = 705,
31 UnsupportedOpenFlags = 760,
32 IncorrectExeFSReadSize = 761,
33 UnexpectedFileOrDirectory = 770,
34}; 14};
35} 15}
36 16
17constexpr ResultCode ERROR_PATH_NOT_FOUND(ErrorModule::FS, ErrCodes::NotFound);
18
37// TODO(bunnei): Replace these with correct errors for Switch OS 19// TODO(bunnei): Replace these with correct errors for Switch OS
38constexpr ResultCode ERROR_INVALID_PATH(ResultCode(-1)); 20constexpr ResultCode ERROR_INVALID_PATH(ResultCode(-1));
39constexpr ResultCode ERROR_UNSUPPORTED_OPEN_FLAGS(ResultCode(-1)); 21constexpr ResultCode ERROR_UNSUPPORTED_OPEN_FLAGS(ResultCode(-1));
40constexpr ResultCode ERROR_INVALID_OPEN_FLAGS(ResultCode(-1)); 22constexpr ResultCode ERROR_INVALID_OPEN_FLAGS(ResultCode(-1));
41constexpr ResultCode ERROR_FILE_NOT_FOUND(ResultCode(-1)); 23constexpr ResultCode ERROR_FILE_NOT_FOUND(ResultCode(-1));
42constexpr ResultCode ERROR_PATH_NOT_FOUND(ResultCode(-1));
43constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY(ResultCode(-1)); 24constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY(ResultCode(-1));
44constexpr ResultCode ERROR_DIRECTORY_ALREADY_EXISTS(ResultCode(-1)); 25constexpr ResultCode ERROR_DIRECTORY_ALREADY_EXISTS(ResultCode(-1));
45constexpr ResultCode ERROR_FILE_ALREADY_EXISTS(ResultCode(-1)); 26constexpr ResultCode ERROR_FILE_ALREADY_EXISTS(ResultCode(-1));