Skip to content

Commit

Permalink
fixed non-latin files/folders
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAaronLopezGarcia committed Jul 6, 2023
1 parent 7d08029 commit 1319978
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 86 deletions.
2 changes: 1 addition & 1 deletion common/include/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#define ARK_MAJOR_VERSION 4
#define ARK_MINOR_VERSION 20
#define ARK_MICRO_VERSION 60
#define ARK_REVISION 2
#define ARK_REVISION 3
#define MAX_FLASH0_SIZE 0x32000

/*
Expand Down
4 changes: 2 additions & 2 deletions extras/menus/arkMenu/include/browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ class Browser : public SystemEntry{

void moveDirUp();

void update(Entry* e, bool skip_prompt);
void update(Entry* ent, bool skip_prompt);

void refreshDirs();
void refreshDirs(const char* retry=NULL);

void drawScreen();

Expand Down
18 changes: 10 additions & 8 deletions extras/menus/arkMenu/include/browser_entries.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ class BrowserFile : public Entry{
bool selected;
string fileSize;
int filetype;
string shortname;
string parent;

virtual unsigned getFileSize();

void setShortName(string shortname);

public:

BrowserFile();

BrowserFile(string path);

BrowserFile(BrowserFile* orig);
BrowserFile(string path, string shortname);
BrowserFile(string parent, string name, string shortname);

~BrowserFile();

Expand Down Expand Up @@ -49,15 +52,14 @@ class BrowserFile : public Entry{
void doExecute();

int getFileType() { return filetype; }

string getFullPath() { return path; }
};

class BrowserFolder : public BrowserFile{
public:
BrowserFolder(string path);

BrowserFolder(BrowserFolder* orig);

BrowserFolder(string parent, string name);
BrowserFolder(string path, string shortname);
BrowserFolder(string parent, string name, string shortname);

~BrowserFolder();

Expand Down
75 changes: 31 additions & 44 deletions extras/menus/arkMenu/src/browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,12 @@ void Browser::moveDirUp(){
this->refreshDirs();
}

void Browser::update(Entry* e, bool skip_prompt){
void Browser::update(Entry* ent, bool skip_prompt){
// Move to the next directory pointed by the currently selected entry or run an app if selected file is one
if (this->entries->size() == 0)
if (ent == NULL || entries->size() == 0)
return;
common::playMenuSound();
BrowserFile* e = (BrowserFile*)ent;
if (e->getName() == "./")
refreshDirs();
else if (e->getName() == "../")
Expand All @@ -158,11 +159,15 @@ void Browser::update(Entry* e, bool skip_prompt){
this->cwd = MS0_DIR;
this->refreshDirs();
}
else if (string(e->getType()) == "FOLDER"){
this->cwd = e->getPath();
this->refreshDirs();
else if (Entry::isARK(e->getPath().c_str())) {
installTheme();
}
else if (e->getFileType() == FOLDER){
string full_path = e->getFullPath();
this->cwd = full_path;
this->refreshDirs(e->getPath().c_str());
}
else if (Iso::isISO(e->getPath().c_str())){
else if (e->getFileType() == FILE_ISO){
if (this->cwd == "ms0:/ISO/VIDEO/" || this->cwd == "ef0:/ISO/VIDEO/")
Iso::executeVideoISO(e->getPath().c_str());
else{
Expand All @@ -179,7 +184,7 @@ void Browser::update(Entry* e, bool skip_prompt){
delete iso;
}
}
else if (Eboot::isEboot(e->getPath().c_str())){
else if (e->getFileType() == FILE_PBP){
Eboot* eboot = new Eboot(e->getPath());
if (!skip_prompt){
is_loading = true;
Expand All @@ -192,33 +197,27 @@ void Browser::update(Entry* e, bool skip_prompt){
else
delete eboot;
}
else if (Entry::isZip(e->getPath().c_str())){
extractArchive(0);
else if (e->getFileType() == FILE_ZIP){
extractArchive(common::getExtension(e->getPath()) == "rar");
}
else if (Entry::isRar(e->getPath().c_str())){
extractArchive(1);
}
else if (Entry::isPRX(e->getPath().c_str())){
else if (e->getFileType() == FILE_PRX){
installPlugin();
}
else if (Entry::isARK(e->getPath().c_str())) {
installTheme();
}
else if (Entry::isTXT(e->getPath().c_str())){
else if (e->getFileType() == FILE_TXT){
optionsmenu = new TextEditor(e->getPath());
optionsmenu->control();
TextEditor* aux = (TextEditor*)optionsmenu;
optionsmenu = NULL;
delete aux;
}
else if (Entry::isIMG(e->getPath().c_str())){
else if (e->getFileType() == FILE_PICTURE){
optionsmenu = new ImageViewer(e->getPath());
optionsmenu->control();
ImageViewer* aux = (ImageViewer*)optionsmenu;
optionsmenu = NULL;
delete aux;
}
else if (Entry::isMusic(e->getPath().c_str())){
else if (e->getFileType() == FILE_MUSIC){
this->hide_main_window = true;
vector<string> selected;
for (int i=0; i<entries->size(); i++){
Expand Down Expand Up @@ -453,7 +452,7 @@ void logbuffer(char* path, void* buffer, u32 size){
sceIoClose(fd);
}

void Browser::refreshDirs(){
void Browser::refreshDirs(const char* retry){

// Refresh the list of files and dirs
SystemMgr::pauseDraw();
Expand Down Expand Up @@ -492,7 +491,11 @@ void Browser::refreshDirs(){

if (dir < 0){ // can't open directory
printf("can't open\n");
if (this->cwd == ROOT_DIR) // ms0 failed
if (retry){
this->cwd = retry;
retry = NULL;
}
else if (this->cwd == ROOT_DIR) // ms0 failed
this->cwd = GO_ROOT; // go to ef0
else
this->cwd = ROOT_DIR;
Expand Down Expand Up @@ -521,30 +524,14 @@ void Browser::refreshDirs(){
continue;
}

string ptmp;
if (FIO_SO_ISDIR(dit->d_stat.st_attr)){
printf("is dir\n");
if (strlen(dit->d_name) < strlen((char*)pri_dirent)){
ptmp = string(this->cwd) + string((const char*)pri_dirent);
printf("%d: %s\n", (int)common::folderExists(ptmp), ptmp.c_str());
}
else{
ptmp = string(this->cwd)+string(dit->d_name);
}
folders.push_back(new Folder(ptmp+"/"));
folders.push_back(new Folder(cwd, dit->d_name, string((const char*)pri_dirent)));
}
else{
printf("is file\n");
if (strlen(dit->d_name) < strlen((char*)pri_dirent)){
ptmp = string(this->cwd) + string((const char*)pri_dirent);
printf("%d: %s\n", (int)common::fileExists(ptmp), ptmp.c_str());
}
else{
ptmp = string(this->cwd)+string(dit->d_name);
}
files.push_back(new File(ptmp));
files.push_back(new File(cwd, dit->d_name, string((const char*)pri_dirent)));
}

}
printf("closing and cleaning\n");
sceIoDclose(dir);
Expand All @@ -571,9 +558,9 @@ void Browser::refreshDirs(){
std::sort(files.begin(), files.end(), Entry::cmpEntriesForSort);
}

if (!dotdot && !isRootDir(this->cwd)) dotdot = new Folder(this->cwd+"../");
if (!dotdot && !isRootDir(this->cwd)) dotdot = new Folder(cwd, "..", "");
if (dotdot) folders.insert(folders.begin(), dotdot);
if (!dot && !isRootDir(this->cwd)) dot = new Folder(this->cwd+"./");
if (!dot && !isRootDir(this->cwd)) dot = new Folder(cwd, ".", "");
if (dot) folders.insert(folders.begin(), dot);

printf("merging entries\n");
Expand All @@ -583,7 +570,7 @@ void Browser::refreshDirs(){
for (int i=0; i<files.size(); i++)
entries->push_back(files.at(i));
if (this->entries->size() == 0)
this->entries->push_back(new Folder("./"));
this->entries->push_back(new Folder(cwd, ".", ""));
SystemMgr::resumeDraw();

printf("done\n");
Expand Down Expand Up @@ -1239,7 +1226,7 @@ void Browser::copyFolder(string path){
if(!strncmp(path.c_str(), this->cwd.c_str(), path.length())) //avoid inception
return;

Folder* f = new Folder(path);
Folder* f = new Folder(path, "");

string destination = checkDestExists(path, this->cwd, f->getName().substr(0, f->getName().length()-1));

Expand Down Expand Up @@ -1699,7 +1686,7 @@ void Browser::control(Controller* pad){
}
else if (pad->start()){
Entry* e = this->get();
if (conf->startbtn == 1) e = new BrowserFile(conf->last_game);
if (conf->startbtn == 1) e = new BrowserFile(conf->last_game, "");
this->update(e, true);
}
else{
Expand Down
68 changes: 43 additions & 25 deletions extras/menus/arkMenu/src/browser_entries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


int fileTypeByExtension(string path){

if (Iso::isISO(path.c_str())){
return FILE_ISO;
}
Expand Down Expand Up @@ -35,28 +34,48 @@ int fileTypeByExtension(string path){
BrowserFile::BrowserFile(){
}

BrowserFile::BrowserFile(string path){
this->icon0 = NULL;
BrowserFile::BrowserFile(string path, string shortname){
size_t lastSlash = path.rfind('/', string::npos);
this->path = path;
size_t lastSlash = path.rfind("/", string::npos);
this->name = path.substr(lastSlash+1, string::npos);
this->parent = path.substr(0, lastSlash) + '/';
this->icon0 = NULL;
this->selected = false;
this->filetype = FOLDER;
this->setShortName(shortname);
this->calcSize();
this->filetype = fileTypeByExtension(path);
this->filetype = fileTypeByExtension(getPath());
}

BrowserFile::BrowserFile(BrowserFile* orig){
this->path = orig->path;
BrowserFile::BrowserFile(string parent, string name, string shortname){
this->icon0 = NULL;
this->path = parent + name;
this->parent = parent;
this->name = name;
this->selected = false;
this->fileSize = orig->fileSize;
this->filetype = orig->filetype;
this->setShortName(shortname);
this->calcSize();
this->filetype = fileTypeByExtension(getPath());
}

BrowserFile::~BrowserFile(){
}

void BrowserFile::setShortName(string shortname){
if (shortname.size() > 0){
if (this->name.size() < shortname.size()){
this->path = this->parent + shortname;
this->name = shortname;
this->shortname = "";
}
else {
this->shortname = shortname;
}
}
}

unsigned BrowserFile::getFileSize(){
return common::fileSize(this->path);
return common::fileSize(getPath());
}

void BrowserFile::calcSize(){
Expand All @@ -79,7 +98,7 @@ void BrowserFile::changeSelection(){
}

string BrowserFile::getPath(){
return this->path;
return (shortname.size() > 0)? parent+shortname : path;
}

string BrowserFile::getName(){
Expand Down Expand Up @@ -130,30 +149,29 @@ void BrowserFile::getTempData2(){
void BrowserFile::doExecute(){
}

BrowserFolder::BrowserFolder(string path){
this->icon0 = NULL;
BrowserFolder::BrowserFolder(string path, string shortname){
size_t lastSlash = path.rfind('/', path.length()-2);
this->path = path;
size_t lastSlash = path.rfind("/", path.length()-2);
this->name = path.substr(lastSlash+1, string::npos);
this->parent = path.substr(0, lastSlash) + '/';
this->icon0 = NULL;
this->selected = false;
this->fileSize = "Folder";
this->filetype = FOLDER;
if (shortname.size() > 0) shortname += '/';
this->setShortName(shortname);
}

BrowserFolder::BrowserFolder(BrowserFolder* orig){
this->path = orig->path;
this->name = orig->name;
this->selected = false;
this->fileSize = "Folder";
this->filetype = FOLDER;
}

BrowserFolder::BrowserFolder(string parent, string name){
this->path = parent;
this->name = name;
BrowserFolder::BrowserFolder(string parent, string name, string shortname){
this->icon0 = NULL;
this->path = parent + name + '/';
this->name = name + '/';
this->parent = parent;
this->selected = false;
this->fileSize = "Folder";
this->filetype = FOLDER;
if (shortname.size() > 0) shortname += '/';
this->setShortName(shortname);
}

BrowserFolder::~BrowserFolder(){
Expand Down
8 changes: 4 additions & 4 deletions extras/menus/arkMenu/src/ftp/ftp_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool FTPDriver::connect(){
printf("Initialize network\n");
if (initializeNetwork() < 0) return false;
printf("connect to access point\n");
if (connect_to_apctl() < 0) return false;
if (!connect_to_apctl()) return false;

bool ret = false;
char tmpText[51];
Expand Down Expand Up @@ -163,7 +163,7 @@ vector<Entry*> FTPDriver::listDirectory(string path){
string file_name(dir->files[i].d_name);
file_name = file_name.substr(file_name.find(' ')+1);
if (FIO_SO_ISDIR(dir->files[i].st_attr)) {
BrowserFolder* folder = new BrowserFolder(path + file_name + "/");
BrowserFolder* folder = new BrowserFolder(path, file_name, "");
printf("adding folder: %s -> %s\n", file_name.c_str(), folder->getName().c_str());
folders.push_back(folder);
} else if (FIO_SO_ISREG(dir->files[i].st_attr)) {
Expand Down Expand Up @@ -195,8 +195,8 @@ vector<Entry*> FTPDriver::listDirectory(string path){
if (dot) folders.insert(folders.begin(), dot);
}

ret.push_back(new BrowserFolder("ftp:/<refresh>"));
ret.push_back(new BrowserFolder("ftp:/<disconnect>"));
ret.push_back(new BrowserFolder("ftp:/", "<refresh>", ""));
ret.push_back(new BrowserFolder("ftp:/", "<disconnect>", ""));

printf("FTP::Folders -> %d\n", folders.size());
for (int i=0; i<folders.size(); i++){
Expand Down
Loading

0 comments on commit 1319978

Please sign in to comment.