mirror of
https://github.com/joel16/CMFileManager-PSP.git
synced 2024-11-23 11:49:51 +00:00
fs: Clean-up paths and allow browsing flash0-3 and disc0
This commit is contained in:
parent
c3760eca6d
commit
55e4eb4a52
@ -39,6 +39,7 @@ namespace FS {
|
||||
int Paste(void);
|
||||
int Move(void);
|
||||
int Delete(SceIoDirent *entry);
|
||||
std::string BuildPath(const std::string &path, const std::string &filename);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
enum MENU_STATES {
|
||||
MENU_STATE_HOME,
|
||||
MENU_STATE_MENUBAR,
|
||||
MENU_STATE_FILEBROWSER,
|
||||
MENU_STATE_OPTIONS,
|
||||
MENU_STATE_DELETE,
|
||||
@ -28,7 +29,7 @@ typedef struct {
|
||||
int checked_count = 0;
|
||||
u64 used_storage = 0;
|
||||
u64 total_storage = 0;
|
||||
g2dTexture *texture;
|
||||
g2dTexture *texture = nullptr;
|
||||
} MenuItem;
|
||||
|
||||
namespace GUI {
|
||||
@ -40,6 +41,10 @@ namespace GUI {
|
||||
void DisplayHomeMenu(void);
|
||||
bool ControlHomeMenu(MenuItem *item, int *ctrl);
|
||||
|
||||
void HandleMenubarAnim(float *delta_time);
|
||||
void DisplayMenubar(void);
|
||||
void ControlMenubar(MenuItem *item, int *ctrl);
|
||||
|
||||
void DisplayFileBrowser(MenuItem *item);
|
||||
void ControlFileBrowser(MenuItem *item, int *ctrl);
|
||||
|
||||
|
@ -11,7 +11,12 @@
|
||||
|
||||
enum BROWSE_STATE {
|
||||
BROWSE_STATE_INTERNAL,
|
||||
BROWSE_STATE_EXTERNAL
|
||||
BROWSE_STATE_EXTERNAL,
|
||||
BROWSE_STATE_FLASH0,
|
||||
BROWSE_STATE_FLASH1,
|
||||
BROWSE_STATE_FLASH2,
|
||||
BROWSE_STATE_FLASH3,
|
||||
BROWSE_STATE_UMD
|
||||
};
|
||||
|
||||
extern bool psp_usb_cable_connection, is_ms_inserted, is_psp_go;
|
||||
|
@ -32,9 +32,13 @@ namespace FS {
|
||||
|
||||
bool DirExists(const std::string &path) {
|
||||
SceUID dir = 0;
|
||||
|
||||
#ifdef FS_DEBUG
|
||||
if (R_SUCCEEDED(dir = sceIoDopen(path.c_str()))) {
|
||||
sceIoDclose(dir);
|
||||
#else
|
||||
if (R_SUCCEEDED(dir = pspOpenDir(path.c_str()))) {
|
||||
pspCloseDir(dir);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -196,16 +200,26 @@ namespace FS {
|
||||
SceUID dir = 0;
|
||||
entries.clear();
|
||||
|
||||
#ifdef FS_DEBUG
|
||||
if (R_FAILED(ret = dir = sceIoDopen(path.c_str()))) {
|
||||
Log::Error("sceIoDopen(%s) failed: %08x\n", path.c_str(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else
|
||||
if (R_FAILED(ret = dir = pspOpenDir(path.c_str()))) {
|
||||
Log::Error("pspOpenDir(%s) failed: %08x\n", path.c_str(), ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
do {
|
||||
SceIoDirent entry;
|
||||
std::memset(&entry, 0, sizeof(entry));
|
||||
|
||||
#ifdef FS_DEBUG
|
||||
ret = sceIoDread(dir, &entry);
|
||||
#else
|
||||
ret = pspReadDir(dir, &entry);
|
||||
#endif
|
||||
if (ret > 0) {
|
||||
if ((std::strcmp(entry.d_name, ".") == 0) || (std::strcmp(entry.d_name, "..") == 0))
|
||||
continue;
|
||||
@ -215,7 +229,12 @@ namespace FS {
|
||||
} while (ret > 0);
|
||||
|
||||
std::sort(entries.begin(), entries.end(), FS::Sort);
|
||||
|
||||
#ifdef FS_DEBUG
|
||||
sceIoDclose(dir);
|
||||
#else
|
||||
pspCloseDir(dir);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -234,43 +253,19 @@ namespace FS {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ChangeDirUp(char path[256]) {
|
||||
if (cfg.cwd.back() == ':')
|
||||
return -1;
|
||||
|
||||
// Remove upmost directory
|
||||
bool copy = false;
|
||||
int len = 0;
|
||||
for (ssize_t i = cfg.cwd.length(); i >= 0; i--) {
|
||||
if (cfg.cwd.c_str()[i] == '/')
|
||||
copy = true;
|
||||
if (copy) {
|
||||
path[i] = cfg.cwd.c_str()[i];
|
||||
len++;
|
||||
}
|
||||
}
|
||||
|
||||
// remove trailing slash
|
||||
if (len > 1 && path[len - 1] == '/')
|
||||
len--;
|
||||
|
||||
path[len] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ChangeDirNext(const std::string &path, std::vector<SceIoDirent> &entries) {
|
||||
std::string new_path = cfg.cwd;
|
||||
new_path.append("/");
|
||||
new_path.append(path);
|
||||
std::string new_path = FS::BuildPath(cfg.cwd, path);
|
||||
return FS::ChangeDir(new_path, entries);
|
||||
}
|
||||
|
||||
int ChangeDirPrev(std::vector<SceIoDirent> &entries) {
|
||||
char new_path[256];
|
||||
if (FS::ChangeDirUp(new_path) < 0)
|
||||
return -1;
|
||||
std::filesystem::path path = cfg.cwd;
|
||||
std::string parent_path = path.parent_path();
|
||||
|
||||
return FS::ChangeDir(std::string(new_path), entries);
|
||||
if (parent_path.back() == ':')
|
||||
parent_path.append("/");
|
||||
|
||||
return FS::ChangeDir(parent_path.empty()? cfg.cwd : parent_path, entries);
|
||||
}
|
||||
|
||||
static int CopyFile(const std::string &src_path, const std::string &dest_path) {
|
||||
@ -344,10 +339,17 @@ namespace FS {
|
||||
int ret = 0;
|
||||
SceUID dir;
|
||||
|
||||
if (R_FAILED(dir = sceIoDopen(src_path.c_str()))) {
|
||||
#ifdef FS_DEBUG
|
||||
if (R_FAILED(ret = dir = sceIoDopen(src_path.c_str()))) {
|
||||
Log::Error("sceIoDopen(%s) failed: %08x\n", src_path.c_str(), ret);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
if (R_FAILED(ret = dir = pspOpenDir(src_path.c_str()))) {
|
||||
Log::Error("pspOpenDir(%s) failed: %08x\n", src_path.c_str(), ret);
|
||||
return dir;
|
||||
}
|
||||
#endif
|
||||
|
||||
// This may fail or not, but we don't care -> make the dir if it doesn't exist, otherwise continue.
|
||||
sceIoMkdir(dest_path.c_str(), 0777);
|
||||
@ -356,18 +358,17 @@ namespace FS {
|
||||
SceIoDirent entry;
|
||||
std::memset(&entry, 0, sizeof(entry));
|
||||
|
||||
#ifdef FS_DEBUG
|
||||
ret = sceIoDread(dir, &entry);
|
||||
#else
|
||||
ret = pspReadDir(dir, &entry);
|
||||
#endif
|
||||
if (ret > 0) {
|
||||
if ((std::strcmp(entry.d_name, ".") == 0) || (std::strcmp(entry.d_name, "..") == 0))
|
||||
continue;
|
||||
|
||||
std::string src = src_path;
|
||||
src.append("/");
|
||||
src.append(entry.d_name);
|
||||
|
||||
std::string dest = dest_path;
|
||||
dest.append("/");
|
||||
dest.append(entry.d_name);
|
||||
std::string src = FS::BuildPath(src_path, entry.d_name);
|
||||
std::string dest = FS::BuildPath(dest_path, entry.d_name);
|
||||
|
||||
if (FIO_S_ISDIR(entry.d_stat.st_mode))
|
||||
FS::CopyDir(src, dest); // Copy Folder (via recursion)
|
||||
@ -376,7 +377,11 @@ namespace FS {
|
||||
}
|
||||
} while (ret > 0);
|
||||
|
||||
#ifdef FS_DEBUG
|
||||
sceIoDclose(dir);
|
||||
#else
|
||||
pspCloseDir(dir);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -388,9 +393,7 @@ namespace FS {
|
||||
|
||||
void Copy(SceIoDirent *entry, const std::string &path) {
|
||||
FS::ClearCopyData();
|
||||
fs_copy_entry.copy_path = path;
|
||||
fs_copy_entry.copy_path.append("/");
|
||||
fs_copy_entry.copy_path.append(entry->d_name);
|
||||
fs_copy_entry.copy_path = FS::BuildPath(path, entry->d_name);
|
||||
fs_copy_entry.copy_filename.append(entry->d_name);
|
||||
|
||||
if (FIO_S_ISDIR(entry->d_stat.st_mode))
|
||||
@ -399,9 +402,7 @@ namespace FS {
|
||||
|
||||
int Paste(void) {
|
||||
int ret = 0;
|
||||
std::string path = cfg.cwd;
|
||||
path.append("/");
|
||||
path.append(fs_copy_entry.copy_filename);
|
||||
std::string path = FS::BuildPath(cfg.cwd, fs_copy_entry.copy_filename);
|
||||
|
||||
if (fs_copy_entry.is_dir) // Copy folder recursively
|
||||
ret = FS::CopyDir(fs_copy_entry.copy_path, path);
|
||||
@ -456,9 +457,7 @@ namespace FS {
|
||||
|
||||
int Move(void) {
|
||||
int ret = 0;
|
||||
std::string path = cfg.cwd;
|
||||
path.append("/");
|
||||
path.append(fs_copy_entry.copy_filename);
|
||||
std::string path = FS::BuildPath(cfg.cwd, fs_copy_entry.copy_filename);
|
||||
|
||||
if (R_FAILED(ret = sceIoMove(fs_copy_entry.copy_path.c_str(), path.c_str()))) {
|
||||
Log::Error("sceIoMove(%s, %s) failed: 0x%x\n", fs_copy_entry.copy_filename.c_str(), path.c_str(), ret);
|
||||
@ -474,31 +473,44 @@ namespace FS {
|
||||
int ret = 0;
|
||||
SceUID dir = 0;
|
||||
|
||||
#ifdef FS_DEBUG
|
||||
if (R_FAILED(ret = dir = sceIoDopen(path.c_str()))) {
|
||||
Log::Error("sceIoDopen(%s) failed: %08x\n", path.c_str(), ret);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
if (R_FAILED(ret = dir = pspOpenDir(path.c_str()))) {
|
||||
if (R_FAILED(ret = sceIoRemove(path.c_str()))) {
|
||||
Log::Error("sceIoRemove(%s) failed: %08x\n", path.c_str(), ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
do {
|
||||
SceIoDirent entry;
|
||||
std::memset(&entry, 0, sizeof(entry));
|
||||
|
||||
#ifdef FS_DEBUG
|
||||
ret = sceIoDread(dir, &entry);
|
||||
#else
|
||||
ret = pspReadDir(dir, &entry);
|
||||
#endif
|
||||
if (ret > 0) {
|
||||
if ((std::strcmp(entry.d_name, ".") == 0) || (std::strcmp(entry.d_name, "..") == 0))
|
||||
continue;
|
||||
|
||||
std::string new_path = path;
|
||||
new_path.append("/");
|
||||
new_path.append(entry.d_name);
|
||||
std::string new_path = FS::BuildPath(path, entry.d_name);
|
||||
|
||||
if (FIO_S_ISDIR(entry.d_stat.st_mode)) {
|
||||
int result = FS::DeleteDirectoryRecursive(new_path);
|
||||
if (result <= 0) {
|
||||
Log::Error("FS::DeleteDirectoryRecursive(%s) failed: %08x\n", path.c_str(), ret);
|
||||
#ifdef FS_DEBUG
|
||||
sceIoDclose(dir);
|
||||
#else
|
||||
pspCloseDir(dir);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@ -506,14 +518,22 @@ namespace FS {
|
||||
int result = sceIoRemove(new_path.c_str());
|
||||
if (R_FAILED(result)) {
|
||||
Log::Error("sceIoRemove(%s) failed: %08x\n", path.c_str(), ret);
|
||||
#ifdef FS_DEBUG
|
||||
sceIoDclose(dir);
|
||||
#else
|
||||
pspCloseDir(dir);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (ret > 0);
|
||||
|
||||
#ifdef FS_DEBUG
|
||||
sceIoDclose(dir);
|
||||
#else
|
||||
pspCloseDir(dir);
|
||||
#endif
|
||||
|
||||
if (R_FAILED(ret = sceIoRmdir(path.c_str()))) {
|
||||
Log::Error("sceIoRmdir(%s) failed: %08x\n", path.c_str(), ret);
|
||||
@ -525,9 +545,7 @@ namespace FS {
|
||||
|
||||
int Delete(SceIoDirent *entry) {
|
||||
int ret = 0;
|
||||
std::string path = cfg.cwd;
|
||||
path.append("/");
|
||||
path.append(entry->d_name);
|
||||
std::string path = FS::BuildPath(cfg.cwd, entry->d_name);
|
||||
|
||||
if (FIO_S_ISDIR(entry->d_stat.st_mode)) {
|
||||
if (R_FAILED(ret = FS::DeleteDirectoryRecursive(path))) {
|
||||
@ -544,4 +562,14 @@ namespace FS {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string BuildPath(const std::string &path, const std::string &filename) {
|
||||
std::string new_path = path;
|
||||
|
||||
if (new_path.back() != '/')
|
||||
new_path.append("/");
|
||||
|
||||
new_path.append(filename);
|
||||
return new_path;
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ static void log_func(ftppsp_log_cb_t log_cb, const char *s, ...) {
|
||||
#define DEBUG(...) log_func(debug_log_cb, __VA_ARGS__)
|
||||
|
||||
static int client_send_ctrl_msg(ftppsp_client_info_t *cl, const char *str) {
|
||||
printf(str);
|
||||
std::printf(str);
|
||||
return sceNetInetSend(cl->ctrl_sockfd, str, std::strlen(str), 0);
|
||||
}
|
||||
|
||||
|
@ -115,6 +115,12 @@ namespace GUI {
|
||||
GUI::DisplayHomeMenu();
|
||||
exit_flag = GUI::ControlHomeMenu(&item, &ctrl);
|
||||
break;
|
||||
|
||||
case MENU_STATE_MENUBAR:
|
||||
GUI::HandleMenubarAnim(&delta_time);
|
||||
GUI::DisplayMenubar();
|
||||
GUI::ControlMenubar(&item, &ctrl);
|
||||
break;
|
||||
|
||||
case MENU_STATE_FILEBROWSER:
|
||||
GUI::ControlFileBrowser(&item, &ctrl);
|
||||
@ -150,7 +156,7 @@ namespace GUI {
|
||||
}
|
||||
|
||||
g2dFlip(G2D_VSYNC);
|
||||
|
||||
|
||||
if (Utils::IsButtonPressed(PSP_CTRL_START))
|
||||
item.state = MENU_STATE_SETTINGS;
|
||||
else if (Utils::IsKButtonPressed(PSP_CTRL_HOME))
|
||||
|
@ -144,5 +144,8 @@ namespace GUI {
|
||||
}
|
||||
else if (Utils::IsButtonPressed(PSP_CTRL_TRIANGLE))
|
||||
item->state = MENU_STATE_OPTIONS;
|
||||
|
||||
if (Utils::IsButtonPressed(PSP_CTRL_SELECT))
|
||||
item->state = MENU_STATE_MENUBAR;
|
||||
}
|
||||
}
|
||||
|
241
app/source/gui/menubar.cpp
Normal file
241
app/source/gui/menubar.cpp
Normal file
@ -0,0 +1,241 @@
|
||||
#include <pspumd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "colours.h"
|
||||
#include "fs.h"
|
||||
#include "g2d.h"
|
||||
#include "gui.h"
|
||||
#include "log.h"
|
||||
#include "textures.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace GUI {
|
||||
static int selection = 0;
|
||||
static float pos_x = -180.f;
|
||||
static const float pos_x_bounds = 0.f;
|
||||
|
||||
void HandleMenubarAnim(float *delta_time) {
|
||||
pos_x += 1000 * (*delta_time);
|
||||
|
||||
if (pos_x > 0)
|
||||
pos_x = pos_x_bounds;
|
||||
}
|
||||
|
||||
void DisplayMenubar(void) {
|
||||
G2D::DrawImage(bg_header, pos_x, 18);
|
||||
G2D::DrawRect(pos_x, 90, 180, 254, BG_COLOUR);
|
||||
G2D::DrawRect(pos_x + 180, 18, 480, 254, G2D_RGBA(0, 0, 0, cfg.dark_theme? 50: 80));
|
||||
G2D::DrawRect(pos_x, 90 + (30 * selection), 180, 30, SELECTOR_COLOUR);
|
||||
|
||||
G2D::FontSetStyle(font, 1.0f, cfg.dark_theme? WHITE : BLACK, INTRAFONT_ALIGN_LEFT);
|
||||
|
||||
if (is_psp_go) {
|
||||
G2D::DrawImage(cfg.dark_theme? icon_sd_dark : icon_sd, pos_x + 10, 92);
|
||||
intraFontPrint(font, pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2), !is_ms_inserted? "ef0:/" : "ms0:/");
|
||||
|
||||
if (is_ms_inserted) {
|
||||
G2D::DrawImage(cfg.dark_theme? icon_secure_dark : icon_secure, pos_x + 10, 122);
|
||||
intraFontPrint(font, pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2) + 30, "ef0:/");
|
||||
|
||||
if (cfg.dev_options) {
|
||||
G2D::DrawImage(cfg.dark_theme? icon_secure_dark : icon_secure, pos_x + 10, 152);
|
||||
intraFontPrint(font, pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2) + 60, "flash0:/");
|
||||
|
||||
G2D::DrawImage(cfg.dark_theme? icon_secure_dark : icon_secure, pos_x + 10, 182);
|
||||
intraFontPrint(font, pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2) + 90, "flash1:/");
|
||||
|
||||
G2D::DrawImage(cfg.dark_theme? icon_secure_dark : icon_secure, pos_x + 10, 212);
|
||||
intraFontPrint(font, pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2) + 120, "flash2:/");
|
||||
|
||||
G2D::DrawImage(cfg.dark_theme? icon_secure_dark : icon_secure, pos_x + 10, 242);
|
||||
intraFontPrint(font, pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2) + 150, "flash3:/");
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (cfg.dev_options) {
|
||||
G2D::DrawImage(cfg.dark_theme? icon_secure_dark : icon_secure, pos_x + 10, 122);
|
||||
intraFontPrint(font, pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2) + 30, "flash0:/");
|
||||
|
||||
G2D::DrawImage(cfg.dark_theme? icon_secure_dark : icon_secure, pos_x + 10, 152);
|
||||
intraFontPrint(font, pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2) + 60, "flash1:/");
|
||||
|
||||
G2D::DrawImage(cfg.dark_theme? icon_secure_dark : icon_secure, pos_x + 10, 182);
|
||||
intraFontPrint(font, pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2) + 90, "flash2:/");
|
||||
|
||||
G2D::DrawImage(cfg.dark_theme? icon_secure_dark : icon_secure, pos_x + 10, 212);
|
||||
intraFontPrint(font, pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2) + 120, "flash3:/");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
G2D::DrawImage(cfg.dark_theme? icon_sd_dark : icon_sd, pos_x + 10, 92);
|
||||
intraFontPrint(font, pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2), "ms0:/");
|
||||
|
||||
if (cfg.dev_options) {
|
||||
G2D::DrawImage(cfg.dark_theme? icon_secure_dark : icon_secure, pos_x + 10, 122);
|
||||
intraFontPrint(font, pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2) + 30, "flash0:/");
|
||||
|
||||
G2D::DrawImage(cfg.dark_theme? icon_secure_dark : icon_secure, pos_x + 10, 152);
|
||||
intraFontPrint(font, pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2) + 60, "flash1:/");
|
||||
|
||||
G2D::DrawImage(cfg.dark_theme? icon_secure_dark : icon_secure, pos_x + 10, 182);
|
||||
intraFontPrint(font, pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2) + 90, "flash2:/");
|
||||
|
||||
G2D::DrawImage(cfg.dark_theme? icon_secure_dark : icon_secure, pos_x + 10, 212);
|
||||
intraFontPrint(font, pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2) + 120, "flash3:/");
|
||||
|
||||
G2D::DrawImage(cfg.dark_theme? icon_secure_dark : icon_secure, pos_x + 10, 242);
|
||||
intraFontPrint(font, pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2) + 150, "disc0:/");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ControlMenubar(MenuItem *item, int *ctrl) {
|
||||
if (*ctrl & PSP_CTRL_UP)
|
||||
selection--;
|
||||
else if (*ctrl & PSP_CTRL_DOWN)
|
||||
selection++;
|
||||
|
||||
if (is_psp_go) {
|
||||
if (cfg.dev_options) {
|
||||
Utils::SetMax(&selection, 0, is_ms_inserted? 5 : 4);
|
||||
Utils::SetMin(&selection, is_ms_inserted? 5 : 4, 0);
|
||||
}
|
||||
else {
|
||||
Utils::SetMax(&selection, 0, is_ms_inserted? 1 : 0);
|
||||
Utils::SetMin(&selection, is_ms_inserted? 1 : 0, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Utils::SetMax(&selection, 0, cfg.dev_options? 5 : 0);
|
||||
Utils::SetMin(&selection, cfg.dev_options? 5 : 0, 0);
|
||||
}
|
||||
|
||||
if (Utils::IsButtonPressed(PSP_CTRL_ENTER)) {
|
||||
unsigned int ret = 0;
|
||||
|
||||
switch (selection) {
|
||||
case 0:
|
||||
if ((is_psp_go && is_ms_inserted) || (!is_psp_go)) {
|
||||
cfg.cwd = "ms0:";
|
||||
device = BROWSE_STATE_EXTERNAL;
|
||||
}
|
||||
else if (is_psp_go && !is_ms_inserted) {
|
||||
cfg.cwd = "ef0:";
|
||||
device = BROWSE_STATE_INTERNAL;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (!(is_psp_go && is_ms_inserted)) {
|
||||
if ((R_FAILED(ret = sceIoUnassign("flash0:"))) && (ret != 0x80020321))
|
||||
Log::Error("sceIoUnassign(flash0) failed: 0x%x\n", ret);
|
||||
|
||||
if (R_FAILED(ret = sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, nullptr, 0)))
|
||||
Log::Error("sceIoAssign(flash0) failed: 0x%x\n", ret);
|
||||
}
|
||||
|
||||
cfg.cwd = (is_psp_go && is_ms_inserted)? "ef0:" : "flash0:/";
|
||||
device = (is_psp_go && is_ms_inserted)? BROWSE_STATE_INTERNAL : BROWSE_STATE_FLASH0;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (is_psp_go && is_ms_inserted) {
|
||||
if ((R_FAILED(ret = sceIoUnassign("flash0:"))) && (ret != 0x80020321))
|
||||
Log::Error("sceIoUnassign(flash0) failed: 0x%x\n", ret);
|
||||
|
||||
if (R_FAILED(ret = sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, nullptr, 0)))
|
||||
Log::Error("sceIoAssign(flash0) failed: 0x%x\n", ret);
|
||||
}
|
||||
else {
|
||||
if ((R_FAILED(ret = sceIoUnassign("flash1:"))) && (ret != 0x80020321))
|
||||
Log::Error("sceIoUnassign(flash1) failed: 0x%x\n", ret);
|
||||
|
||||
if (R_FAILED(ret = sceIoAssign("flash1:", "lflash0:0,1", "flashfat1:", IOASSIGN_RDWR, nullptr, 0)))
|
||||
Log::Error("sceIoAssign(flash1) failed: 0x%x\n", ret);
|
||||
}
|
||||
|
||||
cfg.cwd = (is_psp_go && is_ms_inserted)? "flash0:/" : "flash1:/";
|
||||
device = (is_psp_go && is_ms_inserted)? BROWSE_STATE_FLASH0 : BROWSE_STATE_FLASH1;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (is_psp_go && is_ms_inserted) {
|
||||
if ((R_FAILED(ret = sceIoUnassign("flash1:"))) && (ret != 0x80020321))
|
||||
Log::Error("sceIoUnassign(flash1) failed: 0x%x\n", ret);
|
||||
|
||||
if (R_FAILED(ret = sceIoAssign("flash1:", "lflash0:0,1", "flashfat1:", IOASSIGN_RDWR, nullptr, 0)))
|
||||
Log::Error("sceIoAssign(flash1) failed: 0x%x\n", ret);
|
||||
}
|
||||
else {
|
||||
if ((R_FAILED(ret = sceIoUnassign("flash2:"))) && (ret != 0x80020321))
|
||||
Log::Error("sceIoUnassign(flash2) failed: 0x%x\n", ret);
|
||||
|
||||
if (R_FAILED(ret = sceIoAssign("flash2:", "lflash0:0,2", "flashfat2:", IOASSIGN_RDWR, nullptr, 0)))
|
||||
Log::Error("sceIoAssign(flash2) failed: 0x%x\n", ret);
|
||||
}
|
||||
|
||||
cfg.cwd = (is_psp_go && is_ms_inserted)? "flash1:/" : "flash2:/";
|
||||
device = (is_psp_go && is_ms_inserted)? BROWSE_STATE_FLASH1 : BROWSE_STATE_FLASH2;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (is_psp_go && is_ms_inserted) {
|
||||
if ((R_FAILED(ret = sceIoUnassign("flash2:"))) && (ret != 0x80020321))
|
||||
Log::Error("sceIoUnassign(flash2) failed: 0x%x\n", ret);
|
||||
|
||||
if (R_FAILED(ret = sceIoAssign("flash2:", "lflash0:0,2", "flashfat2:", IOASSIGN_RDWR, nullptr, 0)))
|
||||
Log::Error("sceIoAssign(flash2) failed: 0x%x\n", ret);
|
||||
}
|
||||
else {
|
||||
if ((R_FAILED(ret = sceIoUnassign("flash3:"))) && (ret != 0x80020321))
|
||||
Log::Error("sceIoUnassign(flash3) failed: 0x%x\n", ret);
|
||||
|
||||
if (R_FAILED(ret = sceIoAssign("flash3:", "lflash0:0,3", "flashfat3:", IOASSIGN_RDWR, nullptr, 0)))
|
||||
Log::Error("sceIoAssign(flash3) failed: 0x%x\n", ret);
|
||||
}
|
||||
|
||||
cfg.cwd = (is_psp_go && is_ms_inserted)? "flash2:/" : "flash3:/";
|
||||
device = (is_psp_go && is_ms_inserted)? BROWSE_STATE_FLASH2 : BROWSE_STATE_FLASH3;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if (is_psp_go && is_ms_inserted) {
|
||||
if ((R_FAILED(ret = sceIoUnassign("flash3:"))) && (ret != 0x80020321))
|
||||
Log::Error("sceIoUnassign(flash3) failed: 0x%x\n", ret);
|
||||
|
||||
if (R_FAILED(ret = sceIoAssign("flash3:", "lflash0:0,3", "flashfat3:", IOASSIGN_RDWR, nullptr, 0)))
|
||||
Log::Error("sceIoAssign(flash3) failed: 0x%x\n", ret);
|
||||
|
||||
cfg.cwd = "flash3:/";
|
||||
device = BROWSE_STATE_FLASH3;
|
||||
}
|
||||
else if (!is_psp_go) {
|
||||
if (sceUmdCheckMedium() != 0) {
|
||||
sceUmdActivate(1, "disc0:");
|
||||
sceUmdWaitDriveStat(UMD_WAITFORINIT);
|
||||
|
||||
cfg.cwd = "disc0:";
|
||||
device = BROWSE_STATE_UMD;
|
||||
}
|
||||
else
|
||||
Log::Error("Cannot read UMD drive!\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
pos_x -= 10.0;
|
||||
pos_x = -180;
|
||||
FS::GetDirList(cfg.cwd, item->entries);
|
||||
if ((device == BROWSE_STATE_FLASH0) || (device == BROWSE_STATE_FLASH1) || (device == BROWSE_STATE_FLASH2) || (device == BROWSE_STATE_FLASH3))
|
||||
cfg.cwd.pop_back();
|
||||
|
||||
item->state = MENU_STATE_FILEBROWSER;
|
||||
}
|
||||
else if ((Utils::IsButtonPressed(PSP_CTRL_CANCEL)) || (Utils::IsButtonPressed(PSP_CTRL_SELECT))) {
|
||||
pos_x -= 10.0;
|
||||
pos_x = -180;
|
||||
item->state = MENU_STATE_FILEBROWSER;
|
||||
}
|
||||
}
|
||||
}
|
@ -41,10 +41,8 @@ namespace Options {
|
||||
}
|
||||
|
||||
static void CreateFolder(MenuItem *item) {
|
||||
std::string path = cfg.cwd;
|
||||
path.append("/");
|
||||
std::string name = G2D::KeyboardGetText("Enter folder name", "New folder");
|
||||
path.append(name);
|
||||
std::string path = FS::BuildPath(cfg.cwd, name);
|
||||
|
||||
if (R_SUCCEEDED(FS::MakeDir(path.c_str()))) {
|
||||
FS::GetDirList(cfg.cwd, item->entries);
|
||||
@ -53,10 +51,8 @@ namespace Options {
|
||||
}
|
||||
|
||||
static void CreateFile(MenuItem *item) {
|
||||
std::string path = cfg.cwd;
|
||||
path.append("/");
|
||||
std::string name = G2D::KeyboardGetText("Enter file name", "New File");
|
||||
path.append(name);
|
||||
std::string path = FS::BuildPath(cfg.cwd, name);
|
||||
|
||||
if (R_SUCCEEDED(FS::CreateFile(path.c_str()))) {
|
||||
FS::GetDirList(cfg.cwd, item->entries);
|
||||
@ -65,14 +61,9 @@ namespace Options {
|
||||
}
|
||||
|
||||
static void Rename(MenuItem *item, const std::string &filename) {
|
||||
std::string src_path = cfg.cwd;
|
||||
src_path.append("/");
|
||||
src_path.append(item->entries[item->selected].d_name);
|
||||
|
||||
std::string dest_path = cfg.cwd;
|
||||
dest_path.append("/");
|
||||
std::string src_path = FS::BuildPath(cfg.cwd, item->entries[item->selected].d_name);
|
||||
std::string name = G2D::KeyboardGetText("Enter new name", filename);
|
||||
dest_path.append(name);
|
||||
std::string dest_path = FS::BuildPath(cfg.cwd, name);
|
||||
|
||||
if (R_SUCCEEDED(sceIoRename(src_path.c_str(), dest_path.c_str()))) {
|
||||
FS::GetDirList(cfg.cwd, item->entries);
|
||||
|
Loading…
Reference in New Issue
Block a user