- Timestamp:
- Feb 28, 2010, 5:26:50 PM (15 years ago)
- Location:
- tools/MPQarchiver
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/MPQarchiver/MPQarchiver.depend
r343 r344 1 1 # depslib dependency file v1.0 2 12673 56754source:/var/www/html/tools/MPQarchiver/main.cpp2 1267374258 source:/var/www/html/tools/MPQarchiver/main.cpp 3 3 <iostream> 4 4 "StormLib.h" 5 <dirent.h> 6 <string.h> 5 7 6 8 1267303857 /var/www/html/tools/MPQarchiver/StormLib.h -
tools/MPQarchiver/main.cpp
r343 r344 1 1 #include <iostream> 2 2 #include "StormLib.h" 3 #include <dirent.h> 4 #include <string.h> 3 5 4 6 using namespace std; 5 7 6 static int TestCreateArchiveV2(const char * szMpqCopyName, const char * szFileName) 8 const char* help_msg = "Program for comprimation dir to MPQ file.\n" 9 "Suported by projekt wowpreklad (wowpreklad.zdechov.net).\n\n" 10 "Created by maron\n" 11 "email: maron2@centrum.cz\n\n" 12 "Parameters:\n" 13 " -h --help write this help\n\n" 14 "Usage:\n" 15 "dir - directory to comprimed\n" 16 "file - file name of new MPQ file\n\n" 17 "./MPQarchiver dir file\n"; 18 19 20 int GetDirContent(char * current_dir) 21 { 22 DIR *dp; 23 char nextdir[40]; 24 char * file; 25 26 struct dirent *dirp; 27 if ((dp = opendir(current_dir)) != NULL) { 28 29 30 while ((dirp = readdir(dp)) != NULL) { 31 32 file = dirp->d_name; 33 strcpy(nextdir,current_dir); 34 strncat(nextdir,"/",1); 35 strncat(nextdir,file,strlen(file)); 36 37 38 if (opendir(nextdir) != NULL) 39 { 40 if (memchr (nextdir, '.', strlen(nextdir)) == NULL) 41 GetDirContent(nextdir); 42 } 43 else 44 { 45 printf(nextdir); 46 printf("\n"); 47 } 48 } 49 } 50 51 } 52 53 int main(int argc, char ** argv) 7 54 { 8 55 HANDLE hMpq = NULL; // Handle of created archive 9 HANDLE hFile = INVALID_HANDLE_VALUE;10 char szAddFileName[MAX_PATH] = "";11 int nError = ERROR_SUCCESS;12 56 13 // Create the new file 14 hFile = CreateFile(szMpqCopyName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); 15 if(hFile == INVALID_HANDLE_VALUE) 16 nError = GetLastError(); 17 18 // Write some data 19 if(nError == ERROR_SUCCESS) 20 { 21 SetFilePointer(hFile, 0x100000, NULL, FILE_BEGIN); 22 if(!SetEndOfFile(hFile)) 23 nError = GetLastError(); 24 CloseHandle(hFile); 57 for (int i=0; i<argc; i++) { 58 if (strcmp(argv[i],"-h") == 0 || strcmp(argv[i],"--help") == 0) { 59 printf(help_msg); 60 return EXIT_SUCCESS; 61 } 25 62 } 26 63 27 // Well, now create the MPQ archive 28 if(nError == ERROR_SUCCESS) 29 { 30 printf("Creating %s ...\n", szMpqCopyName); 31 // SFileSetLocale(LANG_CZECH); 32 if(!SFileCreateArchiveEx(szMpqCopyName, 33 MPQ_CREATE_ARCHIVE_V2 | OPEN_ALWAYS, 34 0x100, // dwHashTableSize 35 &hMpq)) 36 nError = GetLastError(); 37 SFileSetLocale(LANG_NEUTRAL); 64 /* if (argc != 3) { 65 printf("Bad count of parameters, write -h for help\n"); 66 return EXIT_FAILURE; 67 } 68 */ 69 argv[2] = "new.mpq"; 70 argv[1] = "test"; 71 72 GetDirContent(argv[1]); 73 74 75 if(!SFileCreateArchiveEx(argv[2], MPQ_CREATE_ARCHIVE_V2 | CREATE_ALWAYS, 0x100, &hMpq)) { 76 printf("Cannot create archive\n"); 38 77 } 39 78 40 // Add the same file multiple times to make archive bigger than 4 GB 41 if(nError == ERROR_SUCCESS) { 42 for(int i = 1; i < 4; i++) 43 { 44 sprintf(szAddFileName, "Data%04u.iso", i); 45 printf("Adding %s ...\n", szAddFileName); 46 if(!SFileAddFile(hMpq, szFileName, szAddFileName, MPQ_FILE_ENCRYPTED)) 47 { 48 printf("Cannot add the file (%u-th pass)\n", i); 49 break; 50 } 51 } 79 if(!SFileAddFile(hMpq, "GameTips.dbc", "GameTips.dbc", 0 )) { 80 printf("Cannot add the file\n"); 52 81 } 53 82 54 if(hMpq != NULL)55 SFileCloseArchive(hMpq);56 return nError;57 }58 59 int main()60 {61 62 HANDLE hMpq = NULL; // Handle of created archive63 64 65 if(!SFileCreateArchiveEx("new.mpq", MPQ_CREATE_ATTRIBUTES | CREATE_ALWAYS, 0x100, &hMpq)) {66 printf("Cannot create archive");67 }68 69 if(!SFileAddFile(hMpq, "GameTips.dbc", "GameTips.dbc", MPQ_FILE_ENCRYPTED | MPQ_FILE_HAS_EXTRA | MPQ_FILE_IMPLODE)) {70 printf("Cannot add the file");71 }72 83 73 84 //TODO: listfile, parametry, help 74 85 75 76 86 SFileCloseArchive(hMpq); 77 87 78 //TestCreateArchiveV2("test2.mpq","GameTips.dbc");79 88 return 0; 80 89 }
Note:
See TracChangeset
for help on using the changeset viewer.