ps3xport
ps3xport copied to clipboard
exception handling for wrong file and directory paths
in my backup are serveral files which have a "" seperator instead of "/", this produce an error for creating directories and files. (Don't know why this inside my backup)
I have added a "replace_str" function which can replace any "" with "/".
You can call this function in archive.c [function: archive_dump]
"snprintf (buffer, sizeof(buffer), "%s/%s", output, replace_str(dir->path, "" , "/"));" and "snprintf (buffer, sizeof(buffer), "%s/%s", output, replace_str(file->path, "" , "/"));"
Is it possible to add this functionality to the "correct" positions in the code.
Thanks
Hi, Can you redirect your ReadIndex command to a file and send me the result or upload the archive.dat file somewhere (it doesn't contain any files, just the listing)? It's very weird that there would be a \ separator in your files as the PS3 doesn't use it as a separator, maybe it's something else... Also, it would be nice if you gave me the replace_str code if you want me to use it :p (it's not hard to do but why waste time on it? :p) Hum... or is it that the archive.dat file you're talking about was created by ps3xport not by the PS3 and you created it on windows? that could explain it then!
Hey
here is a snippet of my ReadIndex This was made from a backup directly from the PS3. I don't have windows running, I am using Linux to work with
-rw-rw-rw- 1040 /dev_hdd0/game/HTSS00003/PARAM.SFO
-rw-rw-rw- 25760 /dev_hdd0/game/HTSS00003/ICON0.PNG
-rw------- 60977 /dev_hdd0/game/BLUS31147_CACHE/ICON0.PNG
-rw-rw-rw- 1496 /dev_hdd0/game/BLUS31147_CACHE/PARAM.SFO
-rw------- 114213 /dev_hdd0/game/BLES01597\ds2gamedata/ICON0.PNG
-rw-rw-rw- 272 /dev_hdd0/game/BLES01597\ds2gamedata/PARAM.SFO
-rw------- 1679360 /dev_hdd0/game/BLES01597\ds2gamedata/ICON1.PAM
-rw------- 1457012 /dev_hdd0/game/BLES01597\ds2gamedata/PIC1.PNG
-rw------- 650260 /dev_hdd0/game/BLES01597\ds2gamedata/SND0.AT3
-rw-rw-rw- 5120 /dev_hdd0/game/BLUS30829/PS3LOGO.DAT
-rw-rw-rw- 308 /dev_hdd0/game/BLUS30829/PARAM.SFO
And here is the replace_str function
char *replace_str(const char *str, const char *old, const char *new)
{
char *ret, *r;
const char *p, *q;
size_t oldlen = strlen(old);
size_t count, retlen, newlen = strlen(new);
int samesize = (oldlen == newlen);
if (!samesize) {
for (count = 0, p = str; (q = strstr(p, old)) != NULL; p = q + oldlen)
count++;
retlen = p - str + strlen(p) + count * (newlen - oldlen);
} else
retlen = strlen(str);
if ((ret = malloc(retlen + 1)) == NULL)
return NULL;
r = ret, p = str;
while (1) {
if (!samesize && !count--)
break;
if ((q = strstr(p, old)) == NULL)
break;
ptrdiff_t l = q - p;
memcpy(r, p, l);
r += l;
memcpy(r, new, newlen);
r += newlen;
p = q + oldlen;
}
strcpy(r, p);
return ret;
}
Humm.. looks like that's from a backup made on the ps3 itself, not from a backup made with ps3xport.. so, does this mean that the directory name contains that "" inside the original backup? I've never seen this and it makes no sense unless the directory name contains the actual "" character, not as a directory separator. In such a case, I don't know if it would work if you dump/recreate the backup, as the directory name would change.. It could work on linux if we keep it that way but on windows, that would be impossible since "" is a reserved character and can't appear in the filename. I'll have to think about this...
Humm.. something for you to look for, can you check the ReadIndex directories, it should print the files then the directories. If it shows /dev_hdd0/game/BLES01597\ds2gamedata/ without showing a /dev_hdd0/game/BLES01597 then it's probably because that directory's name is actually "BLES01597\ds2gamedata", if you have any suggestions on how to allow extracting of such a file, I'd be happy to hear it. Maybe replace the "" with a different special character...
By the way, if you wanted a search/replace for a single char, it would be faster/easier to optimize that function into something like this (could add a strdup() at the start if you don't want to modify the string) :
char *replace_str(char *str, char old, char new)
{
char *p = str;
while (*p != 0) {
if (*p == old)
*p = new;
p++;
}
return str;
}
I have no clue what any of this is, I'm just trying to write a batch script dude lol On Jan 1, 2015 2:34 AM, "Youness Alaoui" [email protected] wrote:
By the way, if you wanted a search/replace for a single char, it would be faster/easier to optimize that function into something like this (could add a strdup() at the start if you don't want to modify the string) :
char _replace_str(char *str, char old, char new) { char *p = str; while (_p != 0) { if (*p == old) *p = new; p++; } return str; }
Reply to this email directly or view it on GitHub https://github.com/kakaroto/ps3xport/issues/2#issuecomment-68481952.
I'm sure that the slashes are facing the right way (I saw the other guy's issue). There's just an extra slash or something. On Jan 1, 2015 2:30 AM, "Youness Alaoui" [email protected] wrote:
Humm.. something for you to look for, can you check the ReadIndex directories, it should print the files then the directories. If it shows /dev_hdd0/game/BLES01597\ds2gamedata/ without showing a /dev_hdd0/game/BLES01597 then it's probably because that directory's name is actually "BLES01597\ds2gamedata", if you have any suggestions on how to allow extracting of such a file, I'd be happy to hear it. Maybe replace the "" with a different special character...
Reply to this email directly or view it on GitHub https://github.com/kakaroto/ps3xport/issues/2#issuecomment-68481912.