Hi Guys,
For my current program, I had difficulty getting it to work in 1.50 kernel mode,
and found the attached code for checking & creating folders was the culprit preventing the program from starting.
Is this usual for sceio commands working with Memorysticks?
This code does work in usermode under 3.xx kernel.
/*
folderexists = 0; // check target folders exist
dfdx = sceIoDopen("ms0:/PICTURE");
if(dfdx >= 0) {folderexists = 1;}
if (folderexists == 0) {sceIoMkdir("ms0:/PICTURE", 0777);}
folderexists = 0;
dfdx = sceIoDopen("ms0:/PICTURE/Maps");
if(dfdx >= 0) {folderexists = 1;}
if (folderexists == 0) {sceIoMkdir("ms0:/PICTURE/Maps", 0777);}
highest = 0; // find highest file number
set_filenum("ms0:/PICTURE/Maps","ms0:/PICTURE/Maps");
nsaved = highest + 1;
*/
sceio commands in 1.50 kernel mode
sceio commands in 1.50 kernel mode
If not actually, then potentially.
When I looked again I saw I missed a function "set_filenum" which checks
for the highest numbered file in a folder.
Still don't think any of this should be illegal in 1.50 kernel since
it is modified ms dumping code.
void build_path(char *output, const char *root, const char *path, int append) {
while(*root != 0) {
*output++ = *root++;
}
if(*(root-1) != '/') {
*output++ = '/';
}
while(*path != 0) {
*output++ = *path++;
}
if(append)
*output++ = '/';
*output++ = 0;
}
void check_file(const char *read_loc, const char *write_loc, const char *name) {
char readpath[256];
build_path(readpath, read_loc, name, 0);
thisfile = 0;
thisfile = thisfile + (readpath[30] - 0x30) * 100000;
thisfile = thisfile + (readpath[31] - 0x30) * 10000;
thisfile = thisfile + (readpath[32] - 0x30) * 1000;
thisfile = thisfile + (readpath[33] - 0x30) * 100;
thisfile = thisfile + (readpath[34] - 0x30) * 10;
thisfile = thisfile + readpath[35] - 0x30;
if (thisfile > highest) {highest = thisfile;}
}
void set_filenum(const char *root, const char *write_loc) {
int dfd;
char next_root[256];
char next_write[256];
dfd = sceIoDopen(root);
if(dfd > 0) {
SceIoDirent dir;
while(sceIoDread(dfd, &dir) > 0) {
if(dir.d_stat.st_attr & FIO_SO_IFDIR) {
if(dir.d_name[0] != '.') {
build_path(next_write, write_loc, dir.d_name, 0);
build_path(next_root, root, dir.d_name, 1);
set_filenum(next_root, next_write);
}
} else {
check_file(root, write_loc, dir.d_name);
}
}
sceIoDclose(dfd);
}
}
for the highest numbered file in a folder.
Still don't think any of this should be illegal in 1.50 kernel since
it is modified ms dumping code.
void build_path(char *output, const char *root, const char *path, int append) {
while(*root != 0) {
*output++ = *root++;
}
if(*(root-1) != '/') {
*output++ = '/';
}
while(*path != 0) {
*output++ = *path++;
}
if(append)
*output++ = '/';
*output++ = 0;
}
void check_file(const char *read_loc, const char *write_loc, const char *name) {
char readpath[256];
build_path(readpath, read_loc, name, 0);
thisfile = 0;
thisfile = thisfile + (readpath[30] - 0x30) * 100000;
thisfile = thisfile + (readpath[31] - 0x30) * 10000;
thisfile = thisfile + (readpath[32] - 0x30) * 1000;
thisfile = thisfile + (readpath[33] - 0x30) * 100;
thisfile = thisfile + (readpath[34] - 0x30) * 10;
thisfile = thisfile + readpath[35] - 0x30;
if (thisfile > highest) {highest = thisfile;}
}
void set_filenum(const char *root, const char *write_loc) {
int dfd;
char next_root[256];
char next_write[256];
dfd = sceIoDopen(root);
if(dfd > 0) {
SceIoDirent dir;
while(sceIoDread(dfd, &dir) > 0) {
if(dir.d_stat.st_attr & FIO_SO_IFDIR) {
if(dir.d_name[0] != '.') {
build_path(next_write, write_loc, dir.d_name, 0);
build_path(next_root, root, dir.d_name, 1);
set_filenum(next_root, next_write);
}
} else {
check_file(root, write_loc, dir.d_name);
}
}
sceIoDclose(dfd);
}
}
If not actually, then potentially.