int SBU::ContentProcess(char* addr, char* Path) { MyFile mydiv; char* outContentPath; char imagePath[256], outContent[256]; char dataPath1[256]; sprintf_s(dataPath1, "%sdata", Path); if(fileName == SBU_MUSIC_FILENAME) { sprintf_s(imagePath, "%s\\%s", dataPath1, SBU_MUSIC_FILENAME); outContentPath = MakeFolder(dataPath1, "musics"); sprintf_s(outContent, "%s\\%s", outContentPath, SBU_MUSIC_FILENAME); mydiv.fileCopy(imagePath, outContent); remove(imagePath); //cout << " [ Dividing..._music ]" << endl; } else if(fileName == SBU_PHOTO_FILENAME) { sprintf_s(imagePath, "%s\\%s", dataPath1, SBU_PHOTO_FILENAME); outContentPath = MakeFolder(dataPath1, "photos"); sprintf_s(outContent, "%s\\%s", outContentPath, SBU_PHOTO_FILENAME); mydiv.fileCopy(imagePath, outContent); remove(imagePath); cout << " [ Dividing... _photo ]" << endl; ImageFinder(Path, outContentPath); } else if(fileName == SBU_VIDEO_FILENAME) { sprintf_s(imagePath, "%s\\%s", dataPath1, SBU_VIDEO_FILENAME); outContentPath = MakeFolder(dataPath1, "videos"); sprintf_s(outContent, "%s\\%s", outContentPath, SBU_VIDEO_FILENAME); mydiv.fileCopy(imagePath, outContent); remove(imagePath); //cout << " [ Dividing..._video ]" << endl; } else if(fileName == SBU_MCONTENT_FILENAME) { sprintf_s(imagePath, "%s\\%s", dataPath1, SBU_MCONTENT_FILENAME); outContentPath = MakeFolder(dataPath1, "others"); sprintf_s(outContent, "%s\\%s", outContentPath, SBU_MCONTENT_FILENAME); mydiv.fileCopy(imagePath, outContent); remove(imagePath); //cout << " [ Dividing..._others ]" << endl; } else return 0; return 1; }
// 複数階層に渡りフォルダを作成 bool MakeFolder_Nest(const char* iFolderName) { int theLength = strlen(iFolderName); char* theFolderName = new char[theLength+1]; memset(theFolderName, '\0', theLength+1); for (int i=0 ; i<theLength ; i++) { if ( iFolderName[i] == '\\' ) if ( !MakeFolder(theFolderName) ) { delete [] theFolderName; return false; } theFolderName[i] = iFolderName[i]; } delete [] theFolderName; return MakeFolder(iFolderName); }
int SBU::SBU_Extractor(char* inputPath, char* outputPath) { int length=0, capture=0, fileCount=0; long offset=0; int start=-1, end=-1; char* dataPath; //memset(folderPath, 0, 256); FILE* sbufile; MyFile mysbu; // 백업파일 열기 fopen_s(&sbufile, inputPath, "rb"); if( sbufile == NULL ) { puts("ReadFile open Error"); return 0; } // 데이터 저장용 폴더 생성 dataPath = MakeFolder(outputPath, "data"); while(1) { fseek(sbufile, 118+38*capture++, SEEK_SET); fread(Signature, 16, 1, sbufile); if(!strncmp(Signature, SBU_END, 8)) break; // 백업 데이터 출력 StartingOffset = mysbu.readNum(sbufile, ftell(sbufile), 8); fseek(sbufile, StartingOffset+22, SEEK_SET); SizeOfData = mysbu.readNum(sbufile, ftell(sbufile), 8); //cout << " " << endl;for(int i=0;i<16;i++)printf("%02X ", Signature[i] & 0xff); //cout << endl << " Data Area : " << StartingOffset+54 << " ~ " << StartingOffset+54+SizeOfData << endl; fileName = FileNameCheck(Signature); extension = ExtensionCheck(Signature); if(fileName == NULL) continue; mysbu.WriteFile(0, StartingOffset+54, StartingOffset+54+SizeOfData, 0, inputPath, dataPath, fileName, fileCount++, extension); ContentProcess(fileName, outputPath); } return fileCount; }