-fixed nand extractor

This commit is contained in:
fix94.1 2012-08-26 12:40:34 +00:00
parent 75ff081c0c
commit 338f552d02
2 changed files with 64 additions and 3 deletions

View File

@ -790,7 +790,7 @@ void Nand::CreatePath(const char *path, ...)
folder[strlen(folder)-1] = 0; folder[strlen(folder)-1] = 0;
char *check = folder; char *check = folder;
while (true) while(true)
{ {
check = strstr(folder, "//"); check = strstr(folder, "//");
if (check != NULL) if (check != NULL)
@ -798,8 +798,7 @@ void Nand::CreatePath(const char *path, ...)
else else
break; break;
} }
__makedir(folder);
fsop_MakeFolder(folder);
free(folder); free(folder);
} }
va_end(args); va_end(args);
@ -1098,3 +1097,64 @@ void Nand::PatchAHB()
} }
} }
} }
/*
part of miniunz.c
Version 1.01e, February 12th, 2005
Copyright (C) 1998-2005 Gilles Vollant
*/
#include <errno.h>
#include <fcntl.h>
#include <utime.h>
struct stat exists;
static int mymkdir(const char* dirname)
{
if(stat(dirname, &exists) == 0)
return 0;
return mkdir(dirname, S_IREAD | S_IWRITE);
}
int Nand::__makedir(char *newdir)
{
if(stat(newdir, &exists) == 0)
return 0;
int len = (int)strlen(newdir);
if(len <= 0)
return 0;
char *buffer = (char*)MEM2_alloc(len + 1);
strcpy(buffer, newdir);
if(buffer[len-1] == '/')
buffer[len-1] = '\0';
if(mymkdir(buffer) == 0)
{
MEM2_free(buffer);
return 1;
}
char *p = buffer + 1;
while(1)
{
char hold;
while(*p && *p != '\\' && *p != '/')
p++;
hold = *p;
*p = 0;
if((mymkdir(buffer) == -1) && (errno == ENOENT))
{
gprintf("couldn't create directory %s\n",buffer);
MEM2_free(buffer);
return 0;
}
if(hold == 0)
break;
*p++ = hold;
}
MEM2_free(buffer);
return 1;
}

View File

@ -111,6 +111,7 @@ private:
s32 __FlashNandFolder(const char *source, const char *dest); s32 __FlashNandFolder(const char *source, const char *dest);
s32 __DumpNandFile(const char *source, const char *dest); s32 __DumpNandFile(const char *source, const char *dest);
s32 __DumpNandFolder(const char *source, const char *dest); s32 __DumpNandFolder(const char *source, const char *dest);
int __makedir(char *newdir);
u32 MountedDevice; u32 MountedDevice;
u32 EmuDevice; u32 EmuDevice;