diff options
Diffstat (limited to 'tools/dtputil')
-rw-r--r-- | tools/dtputil/anmutil.cpp | 63 | ||||
-rwxr-xr-x | tools/dtputil/build | 3 | ||||
-rw-r--r-- | tools/dtputil/dtputil.cpp | 43 |
3 files changed, 109 insertions, 0 deletions
diff --git a/tools/dtputil/anmutil.cpp b/tools/dtputil/anmutil.cpp new file mode 100644 index 0000000..6636e2c --- /dev/null +++ b/tools/dtputil/anmutil.cpp @@ -0,0 +1,63 @@ +#include "../../include/smdatapack.hpp" +#include <cstdio> +#include <cstdlib> +#include <cstring> +int main(int argc,char** argv) +{ + if(argc<3) + return printf("usage: %s <r/w> <anmfilename> [filetoread1/filetowrite1] ...\n",argv[0]),1; + if(argv[1][0]=='w') + { + smDtpFileW file; + for(int i=3;i<argc;++i) + { + char* rp=argv[i]; + if(*rp=='.'&&*(rp+1)=='/')rp+=2; + if(!file.addFile(rp,argv[i])) + printf("error adding file: %s\n",argv[i]); + } + char *wn=new char[strlen(argv[2])+10]; + strcat(wn,".writing"); + file.writeDtp(wn); + char comm[256]; + sprintf(comm,"zcat %s > %s",wn,argv[2]); + if(system(comm)) + puts("Error while trying decompressing the file, you may have to decompress it yourself."); + else{sprintf(comm,"rm %s",wn);system(comm);} + delete wn; + } + if(argv[1][0]=='r') + { + smDtpFileR file; + FILE *pFile;DWORD size,rsize;char *buff; + pFile=fopen(argv[2],"rb"); + if(!pFile)return 0; + fseek(pFile,0,SEEK_END);size=ftell(pFile);rewind(pFile); + buff=(char*)malloc(sizeof(char)*size); + if(!buff)return 0; + rsize=fread(buff,1,size,pFile); + if(rsize!=size)return 0; + file.openDtpFromMemory(buff,size); + if(argc==3) + { + for(char* c=file.getFirstFile();c;c=file.getNextFile(c)) + { + puts(c); + char *ptr=file.getFilePtr(c); + if(!ptr)printf("error\n");else + printf("size:%lu, first bytes:%c%c%c\n",file.getFileSize(c),*ptr,*(ptr+1),*(ptr+2)); + file.releaseFilePtr(c); + } + } + else + for(int i=3;i<argc;++i) + { + char *ptr=file.getFilePtr(argv[i]); + printf("size:%lu, first bytes:%c%c%c\n",file.getFileSize(argv[i]),*ptr,*(ptr+1),*(ptr+2)); + file.releaseFilePtr(argv[i]); + } + file.closeDtp(); + free(buff); + fclose(pFile); + } +} diff --git a/tools/dtputil/build b/tools/dtputil/build new file mode 100755 index 0000000..7093351 --- /dev/null +++ b/tools/dtputil/build @@ -0,0 +1,3 @@ +#!/bin/bash +g++ dtputil.cpp -Wall -o dtputil -lz -Wl,../../extensions/libsmeltext.a -g +g++ anmutil.cpp -Wall -o anmutil -lz -Wl,../../extensions/libsmeltext.a -g
\ No newline at end of file diff --git a/tools/dtputil/dtputil.cpp b/tools/dtputil/dtputil.cpp new file mode 100644 index 0000000..142a679 --- /dev/null +++ b/tools/dtputil/dtputil.cpp @@ -0,0 +1,43 @@ +#include "../../include/smdatapack.hpp" +#include <cstdio> +int main(int argc,char** argv) +{ + if(argc<3) + return printf("usage: %s <r/w> <dtpfilename> [filetoread1/filetowrite1] ...\n",argv[0]),1; + if(argv[1][0]=='w') + { + smDtpFileW file; + for(int i=3;i<argc;++i) + { + char* rp=argv[i]; + if(*rp=='.'&&*(rp+1)=='/')rp+=2; + if(!file.addFile(rp,argv[i])) + printf("error adding file: %s\n",argv[i]); + } + file.writeDtp(argv[2]); + } + if(argv[1][0]=='r') + { + smDtpFileR file; + file.openDtp(argv[2]); + if(argc==3) + { + for(char* c=file.getFirstFile();c;c=file.getNextFile(c)) + { + puts(c); + char *ptr=file.getFilePtr(c); + if(!ptr)printf("error\n");else + printf("size:%lu, first bytes:%c%c%c\n",file.getFileSize(c),*ptr,*(ptr+1),*(ptr+2)); + file.releaseFilePtr(c); + } + } + else + for(int i=3;i<argc;++i) + { + char *ptr=file.getFilePtr(argv[i]); + printf("size:%lu, first bytes:%c%c%c\n",file.getFileSize(argv[i]),*ptr,*(ptr+1),*(ptr+2)); + file.releaseFilePtr(argv[i]); + } + file.closeDtp(); + } +} |