>> Edit article
이름
제목
패스워드
이거.. 라이선스는 어떻게 되죠? GPL로 공개하신건가요? 데비안 패키지로도 만들어 보려구요.. : 전에 하이텔에 올렸던 소스입니다. 인터넷에 올라온 동영상 파일들을 보면 : xxx.001, xxx.002 이렇게 이름 붙은 것들이 있죠? rzsplit라는 유틸리티로 : 분할한 것으로 rzjoin 유틸리티로 합칠 수 있습니다. : 리눅스에서 어떻게 이런 파일을 합쳐볼려구 제가 어찌어찌 만들어 봤습니 : 다. 소스는 허접하지만, 지금까지 문제없이 잘 동작하네요. 어쩌다 윈도우즈 : 에서는 잘 join이 안되는 파일도 이걸로는 잘 합쳐집니다. : -- 신기하다 --;; : : 아래는 소스입니다. 유닉스에서 cc -o rzjoin rzjoin.c 하면 컴팔됩니다. : 사용법은 rzjoin xxx.001 입니다. : : /* : * Made by Jung, Doyou(벌레잡이) <doyou89@kornet.net> : * 2001.06.17 : * : * Join the split files by rzsplit. : */ : : #include <stdio.h> : : /* The return value of functions */ : #define SUCCESS 1 : #define FAIL 0 : : /* The maximum header size to be read by RZjoin */ : #define MAX_HEADER_SIZE 100 : #define MAX_BUFFER_SIZE 102400 : : /* tag */ : #define END_OF_HEADER 0x2F : #define SPACE 0x20 : : /*#define DEBUG*/ : : int RZ_openFile(char *p_sFileName, FILE **fp, char *p_sHeader) : { : int iRet; : : *fp = fopen (p_sFileName, "r"); : if ( *fp == NULL) : return FAIL; : : /* read header from the file */ : iRet = fread (p_sHeader, MAX_HEADER_SIZE, 1, *fp); : if ( iRet == 0) { : fclose (*fp); : return FAIL; : } : : return SUCCESS; : } : : int RZ_openResultFile(char *p_sFileName, FILE **fp) : { : *fp = fopen (p_sFileName, "w"); : if ( *fp == NULL) : return FAIL; : : return SUCCESS; : } : : int RZ_getResultFileName_Size(int *p_iByteRead, char : *p_sResultFileName, int *p_iResultFileSize, char *p_sHeader) : { : int iByteRead, i; : char sFileSize[21]; : : iByteRead = 0; : : #ifdef DEBUG : printf ("Get the output filename."); : #endif : /* read the result file name */ : while ( *p_sHeader != END_OF_HEADER ) { : /* 3 consecutive spaces means end of filename. */ : if ( *p_sHeader == SPACE && : *(p_sHeader+1) == SPACE && : *(p_sHeader+2) == SPACE ) : break; : : *p_sResultFileName++ = *p_sHeader++; : iByteRead++; : } : : #ifdef DEBUG : printf ("put ending mark & skip the spaces."); : #endif : : /* if there is no filename, it's error. */ : if ( iByteRead == 0 || *p_sHeader == END_OF_HEADER ) : return FAIL; : : /* put ending mark */ : *p_sResultFileName = 0; : #ifdef DEBUG : printf ("The output filename is %s.", p_sResultFileName); : #endif : : /* skip the spaces */ : while ( *p_sHeader == SPACE ) { : p_sHeader++; : iByteRead++; : } : : #ifdef DEBUG : printf ("Get the size of the output file."); : #endif : i = 0; : /* read the result file size */ : #ifdef DEBUG : printf ("header : %d.", *p_sHeader); : #endif : while ( *p_sHeader != END_OF_HEADER ) { : #ifdef DEBUG : printf ("header : %d.", *p_sHeader); : #endif : sFileSize[i++] = *p_sHeader++; : iByteRead++; : } : sFileSize[i] = 0; /* put ending mark */ : : #ifdef DEBUG : printf ("convert filesize string to integer."); : #endif : /* convert filesize string to integer. */ : *p_iResultFileSize = atoi(sFileSize); : if ( *p_iResultFileSize == 0 ) { : #ifdef DEBUG : printf ("file size is %s.", sFileSize); : #endif : return FAIL; : } : : #ifdef DEBUG : printf ("Get the start point of the result file."); : #endif : /* set the start point of the result file */ : *p_iByteRead = iByteRead + 1; : : return SUCCESS; : } : : int RZ_getNextFile(char *p_sFileName, FILE **fp) : { : int iLen; : char *p_ptr; : : iLen = strlen (p_sFileName); : p_ptr = p_sFileName + iLen - 1; : : if ( *p_ptr < '9' ) : *p_ptr += 1; : else { : *p_ptr = '0'; : if ( *(p_ptr-1) < '9' ) : *(p_ptr-1) += 1; : else { : *(p_ptr-1) = '0'; : if ( *(p_ptr-2) < '9' ) : *(p_ptr-2) += 1; : else : return FAIL; : } : } : : *fp = fopen (p_sFileName, "r"); : if ( *fp == NULL) { : #ifdef DEBUG : printf ("file, %s do not exists.", p_sFileName); : #endif : return FAIL; : } : : printf ("Read %s", p_sFileName); : : return SUCCESS; : } : : int RZ_joining(int iByteRead, int iResultFileSize, char *p_sFileName, : char *p_sResultFileName) : { : char sBuffer[MAX_BUFFER_SIZE+1]; : int iRet, iReadSize; : int iTotalWrite; : FILE *fp, *fpOut; : : /* open result file to be joined. */ : if ( !RZ_openResultFile (p_sResultFileName, &fpOut) ) { : printf ("Error in opening file, %s.", p_sResultFileName); : return FAIL; : } : : /* Initialize filename */ : p_sFileName[strlen(p_sFileName)-1] = '0'; : RZ_getNextFile (p_sFileName, &fp); : : /* read out the header scope. */ : fread (sBuffer, iByteRead, 1, fp); : : iTotalWrite = 0; : do { : : /* do the file copy */ : while ( (iReadSize = fread (sBuffer, 1, MAX_BUFFER_SIZE, fp)) ! : = 0 ) { : iRet = fwrite (sBuffer, iReadSize, 1, fpOut); : iTotalWrite += iReadSize; : : if ( iRet == 0 ) { : printf ("Error in writing the result file."); : return FAIL; : } : } : fclose (fp); : : iRet = RZ_getNextFile (p_sFileName, &fp); : #ifdef DEBUG : printf ("The result of RZ_getNextFile() is %d.", iRet); : #endif : : } while ( iRet ) ; : : if ( iTotalWrite != iResultFileSize ) { : printf ("Differ in file size!!!"); : printf ("Expected file size : %d, real writing size : %d", : iResultFileSize, iTotalWrite); : return FAIL; : } : : /*fclose (fp);*/ : fclose (fpOut); : : return SUCCESS; : } : : : main(int argv, char *argc[]) : { : char sFileName[256]; : int iByteRead; : char sResultFileName[256]; : int iResultFileSize; : char sHeader[MAX_HEADER_SIZE+1]; : FILE *fp; : : if ( argv < 2 ) { : printf (""); : printf ("Author : Jung, Doyou(벌레잡이) : <doyou89@kornet.net>"); : printf (" made at 19 Jun, 2001."); : printf (""); : printf ("USAGE : rzjoin <file-to-be-joined>"); : printf (""); : exit (0); : } : strcpy (sFileName, argc[1]); : #ifdef DEBUG : printf ("file, %s will be open.", sFileName); : #endif : : /* open the source file to be joined. */ : if ( !RZ_openFile (sFileName, &fp, sHeader) ) { : printf ("Error in opening file, %s.", sFileName); : exit (1); : } : #ifdef DEBUG : printf ("file, %s opened.", sFileName); : #endif : : : /* get the result filename and size */ : if ( !RZ_getResultFileName_Size (&iByteRead, sResultFileName, : &iResultFileSize, sHeader) ) { : printf ("Could not get the result filename and size."); : exit (1); : } : : fclose (fp); : : printf (""); : printf ("result file name : %s",sResultFileName); : printf ("result file size : %i",iResultFileSize); : printf (""); : : /* start joining */ : if ( !RZ_joining (iByteRead, iResultFileSize, sFileName, : sResultFileName) ) { : printf ("Error in joining file, %s.", sResultFileName); : exit (1); : } : : printf (""); : printf ("rzjoin complete.."); : : } : : -- : O.O : |____
Copyleft
1999-2026 by
JSBoard Open Project
Theme Designed by
IDOO
All right reserved