Code: Select all
#include <stdio.h>
#include <string.h>
#include <libmc.h>
#include <sifrpc.h>
#include <sys/stat.h>
#include <loadfile.h>
#include <sbv_patches.h>
typedef struct {
char nothing[32];
int dircheck;
char something[256];
} entries;
void LoadModules(void)
{
int ret;
ret = SifLoadModule("rom0:SIO2MAN", 0, NULL);
if (ret < 0) {
printf("Failed to load module: SIO2MAN");
}
ret = SifLoadModule("rom0:MCMAN", 0, NULL);
if (ret < 0) {
printf("Failed to load module: MCMAN");
}
ret = SifLoadModule("rom0:MCSERV", 0, NULL);
if (ret < 0) {
printf("Failed to load module: MCSERV");
}
}
static inline char* strzncpy(char *d, char *s, int l) { d[0] = 0; return strncat(d, s, l); }
int main() {
SifInitRpc(0);
sbv_patch_enable_lmb();
sbv_patch_disable_prefix_check();
LoadModules();
mcInit(MC_TYPE_MC);
entries FileEntry[2048];
char path[4096];
strcpy(path,"mc0:/");
int i,dd;
int n = 0;
fio_dirent_t buf;
dd = fioDopen(path);
while(fioDread(dd,&buf)) { //list entries
if((FIO_SO_ISDIR(buf.stat.mode)) && (!strcmp(buf.name,".") || !strcmp(buf.name,"..")))
continue;
if(FIO_SO_ISDIR(buf.stat.mode)) {
FileEntry[n].dircheck = 1;
strcpy(FileEntry[n].something,buf.name); //filename
strzncpy(FileEntry[n].nothing,FileEntry[n].something,31); //displayname
n++;
}
if(n>2046) break;
}
fioDclose(dd);
for(i=0;i<(n-1);i++) {
strcpy(path,"mc0:/");
if(strchr(path,'/') == NULL) {}; //used for checking if coming from device list in browser
strcat(path,FileEntry[i].something); //folder "i" selected
strcat(path,"/"); //append delimiter which wasn't working e.g. "mc0:/FOLDRR" would still be in path afterwards
if(i>0) //append something else to it which wasn't working
strcat(path,FileEntry[i-1].something);
else
strcat(path,FileEntry[i+1].something);
strcat(path,"/");
printf("%s\n",path);
}
return 0;
}
Code: Select all
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
#
# $Id: Makefile.sample 1150 2005-06-12 11:42:08Z pixel $
EE_BIN = stringy.elf
EE_CFLAGS = -O3 -Winline -ffast-math -finline-functions -fstrict-aliasing -funsigned-char -fomit-frame-pointer -funroll-loops
EE_LIBS = -lmc -lpatches
EE_OBJS = stringy.o
all: $(EE_BIN)
clean:
rm -f *.elf *.o
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal