forked from suyu/suyu
added an early function for booting from a directory
This commit is contained in:
parent
539bf8bc86
commit
4c24ea3d88
2 changed files with 35 additions and 16 deletions
|
@ -24,19 +24,38 @@
|
||||||
|
|
||||||
#include "file_util.h"
|
#include "file_util.h"
|
||||||
#include "loader.h"
|
#include "loader.h"
|
||||||
|
#include "system.h"
|
||||||
|
#include "file_sys/directory_file_system.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool _Load_BIN(std::string &filename) {
|
bool LoadDirectory(std::string &filename) {
|
||||||
File::IOFile f(filename, "rb");
|
std::string full_path = filename;
|
||||||
if (f.IsOpen()) {
|
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....
|
// TODO(ShizZy): read here to memory....
|
||||||
}
|
//}
|
||||||
|
ERROR_LOG(TIME, "Unimplemented function!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Loader {
|
namespace Loader {
|
||||||
|
|
||||||
|
bool IsBootableDirectory() {
|
||||||
|
ERROR_LOG(TIME, "Unimplemented function!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identifies the type of a bootable file
|
* Identifies the type of a bootable file
|
||||||
* @param filename String filename of 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) : "";
|
std::string extension = filename.size() >= 5 ? filename.substr(filename.size() - 4) : "";
|
||||||
|
|
||||||
if (File::IsDirectory(filename)) {
|
if (File::IsDirectory(filename)) {
|
||||||
return FILETYPE_NORMAL_DIRECTORY;
|
if (IsBootableDirectory()) {
|
||||||
} else if (!strcasecmp(extension.c_str(),".bin")) {
|
return FILETYPE_CTR_DIRECTORY;
|
||||||
return FILETYPE_3DS_BIN;
|
} else {
|
||||||
|
return FILETYPE_NORMAL_DIRECTORY;
|
||||||
|
}
|
||||||
} else if (!strcasecmp(extension.c_str(),".zip")) {
|
} else if (!strcasecmp(extension.c_str(),".zip")) {
|
||||||
return FILETYPE_ARCHIVE_ZIP;
|
return FILETYPE_ARCHIVE_ZIP;
|
||||||
} else if (!strcasecmp(extension.c_str(),".rar")) {
|
} 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!
|
// Note that this can modify filename!
|
||||||
switch (IdentifyFile(filename)) {
|
switch (IdentifyFile(filename)) {
|
||||||
|
|
||||||
case FILETYPE_3DS_BIN:
|
case FILETYPE_CTR_DIRECTORY:
|
||||||
{
|
{
|
||||||
INFO_LOG(LOADER,"File is a BIN !");
|
INFO_LOG(LOADER,"File is a BIN !");
|
||||||
return _Load_BIN(filename);
|
return LoadDirectory(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
case FILETYPE_ERROR:
|
case FILETYPE_ERROR:
|
||||||
|
|
|
@ -34,14 +34,12 @@ namespace Loader {
|
||||||
enum FileType {
|
enum FileType {
|
||||||
FILETYPE_ERROR,
|
FILETYPE_ERROR,
|
||||||
|
|
||||||
FILETYPE_3DS_CCI,
|
FILETYPE_CTR_CCI,
|
||||||
FILETYPE_3DS_CIA,
|
FILETYPE_CTR_CIA,
|
||||||
FILETYPE_3DS_CXI,
|
FILETYPE_CTR_CXI,
|
||||||
|
FILETYPE_CTR_ELF,
|
||||||
|
|
||||||
FILETYPE_3DS_BIN,
|
FILETYPE_CTR_DIRECTORY,
|
||||||
FILETYPE_3DS_ELF,
|
|
||||||
|
|
||||||
FILETYPE_CTR_DISC_DIRECTORY,
|
|
||||||
|
|
||||||
FILETYPE_UNKNOWN_BIN,
|
FILETYPE_UNKNOWN_BIN,
|
||||||
FILETYPE_UNKNOWN_ELF,
|
FILETYPE_UNKNOWN_ELF,
|
||||||
|
|
Loading…
Reference in a new issue