2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

added an early function for booting from a directory

This commit is contained in:
ShizZy 2013-10-01 19:09:49 -04:00
parent 539bf8bc86
commit 4c24ea3d88
2 changed files with 35 additions and 16 deletions

View file

@ -24,19 +24,38 @@
#include "file_util.h"
#include "loader.h"
#include "system.h"
#include "file_sys/directory_file_system.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
bool _Load_BIN(std::string &filename) {
File::IOFile f(filename, "rb");
if (f.IsOpen()) {
bool LoadDirectory(std::string &filename) {
std::string full_path = filename;
std::string path, file, extension;
SplitPath(ReplaceAll(full_path, "\\", "/"), &path, &file, &extension);
#if EMU_PLATFORM == PLATFORM_WINDOWS
path = ReplaceAll(path, "/", "\\");
#endif
DirectoryFileSystem *fs = new DirectoryFileSystem(&System::g_ctr_file_system, path);
System::g_ctr_file_system.Mount("fs:", fs);
std::string final_name = "fs:/" + file + extension;
//File::IOFile f(filename, "rb");
//if (f.IsOpen()) {
// TODO(ShizZy): read here to memory....
}
//}
ERROR_LOG(TIME, "Unimplemented function!");
return true;
}
namespace Loader {
bool IsBootableDirectory() {
ERROR_LOG(TIME, "Unimplemented function!");
return true;
}
/**
* Identifies the type of a bootable file
* @param filename String filename of bootable file
@ -51,9 +70,11 @@ FileType IdentifyFile(std::string &filename) {
std::string extension = filename.size() >= 5 ? filename.substr(filename.size() - 4) : "";
if (File::IsDirectory(filename)) {
return FILETYPE_NORMAL_DIRECTORY;
} else if (!strcasecmp(extension.c_str(),".bin")) {
return FILETYPE_3DS_BIN;
if (IsBootableDirectory()) {
return FILETYPE_CTR_DIRECTORY;
} else {
return FILETYPE_NORMAL_DIRECTORY;
}
} else if (!strcasecmp(extension.c_str(),".zip")) {
return FILETYPE_ARCHIVE_ZIP;
} else if (!strcasecmp(extension.c_str(),".rar")) {
@ -77,10 +98,10 @@ bool LoadFile(std::string &filename, std::string *error_string) {
// Note that this can modify filename!
switch (IdentifyFile(filename)) {
case FILETYPE_3DS_BIN:
case FILETYPE_CTR_DIRECTORY:
{
INFO_LOG(LOADER,"File is a BIN !");
return _Load_BIN(filename);
return LoadDirectory(filename);
}
case FILETYPE_ERROR:

View file

@ -34,14 +34,12 @@ namespace Loader {
enum FileType {
FILETYPE_ERROR,
FILETYPE_3DS_CCI,
FILETYPE_3DS_CIA,
FILETYPE_3DS_CXI,
FILETYPE_CTR_CCI,
FILETYPE_CTR_CIA,
FILETYPE_CTR_CXI,
FILETYPE_CTR_ELF,
FILETYPE_3DS_BIN,
FILETYPE_3DS_ELF,
FILETYPE_CTR_DISC_DIRECTORY,
FILETYPE_CTR_DIRECTORY,
FILETYPE_UNKNOWN_BIN,
FILETYPE_UNKNOWN_ELF,