// opens up a file from the filesystem and scans it for known formats bool VGMRoot::OpenRawFile(const wstring& filename) { RawFile* newRawFile = new RawFile(filename); if (!newRawFile->open(filename)) { delete newRawFile; return false; } //if the file was set up properly, apply loaders, scan it, and add it to our list if it contains vgmfiles return SetupNewRawFile(newRawFile); }
const wchar_t *NDS2SFLoader::load_psf_libs(PSFFile &psf, RawFile *file, unsigned char *&exebuffer, size_t &exebuffersize) { char libTagName[16]; int libIndex = 1; while (true) { if (libIndex == 1) strcpy(libTagName, "_lib"); else sprintf(libTagName, "_lib%d", libIndex); map<string, string>::iterator itLibTag = psf.tags.find(libTagName); if (itLibTag == psf.tags.end()) break; wchar_t tempfn[PATH_MAX] = {0}; mbstowcs(tempfn, itLibTag->second.c_str(), itLibTag->second.size()); wchar_t *fullPath; fullPath = GetFileWithBase(file->GetFullPath(), tempfn); // TODO: Make sure to limit recursion to avoid crashing. RawFile *newRawFile = new RawFile(fullPath); const wchar_t *psflibError = NULL; if (newRawFile->open(fullPath)) psflibError = psf_read_exe(newRawFile, exebuffer, exebuffersize); else psflibError = L"Unable to open lib file."; delete fullPath; delete newRawFile; if (psflibError != NULL) return psflibError; libIndex++; } return NULL; }