From 338f552d022fb02c0feebe9ba5ea3973dc91e3a9 Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Sun, 26 Aug 2012 12:40:34 +0000 Subject: [PATCH] -fixed nand extractor --- source/channel/nand.cpp | 66 +++++++++++++++++++++++++++++++++++++++-- source/channel/nand.hpp | 1 + 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/source/channel/nand.cpp b/source/channel/nand.cpp index 0d55f09c..7151e1b3 100644 --- a/source/channel/nand.cpp +++ b/source/channel/nand.cpp @@ -790,7 +790,7 @@ void Nand::CreatePath(const char *path, ...) folder[strlen(folder)-1] = 0; char *check = folder; - while (true) + while(true) { check = strstr(folder, "//"); if (check != NULL) @@ -798,8 +798,7 @@ void Nand::CreatePath(const char *path, ...) else break; } - - fsop_MakeFolder(folder); + __makedir(folder); free(folder); } 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 +#include +#include + +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; +} diff --git a/source/channel/nand.hpp b/source/channel/nand.hpp index f571b92e..fcc7cb7e 100644 --- a/source/channel/nand.hpp +++ b/source/channel/nand.hpp @@ -111,6 +111,7 @@ private: s32 __FlashNandFolder(const char *source, const char *dest); s32 __DumpNandFile(const char *source, const char *dest); s32 __DumpNandFolder(const char *source, const char *dest); + int __makedir(char *newdir); u32 MountedDevice; u32 EmuDevice;