U E D R , A S I H C RSS

데블스캠프2006/화요일/tar/나휘동

== tar&untar ==

~cpp
#include <io.h>
#include <stdio.h>

void main()
{
// tar
	FILE * to= fopen("tar.dat", "wb");
	FILE * from;
	const int MAX_BUF= 1024;
	char buffer[MAX_BUF];
	_finddata_t file;
	int handle= _findfirst("tar\*", &file);
	while( _findnext(handle, &file)==0 ){
		if (!(file.attrib & _A_SUBDIR )){
			fwrite( &file, sizeof(_finddata_t), 1, to);
			sprintf(buffer, "tar\%s", file.name);
			from= fopen(buffer, "rb");
			for ( unsigned int i= 0 ; i < file.size ; i++ )
				fputc(fgetc(from), to);
			fclose(from);
		}
	}
	fclose(to);

// untar
	from= fopen("tar.dat", "rb");
	while( fread(&file, sizeof(_finddata_t), 1, from) ){
		sprintf(buffer, "untar\%s", file.name);
		to= fopen(buffer, "wb");
		for( unsigned int i= 0 ; i < file.size ; i++ )
			fputc(fgetc(from), to);
		fclose(to);
	}
	fclose(to);
}

데블스캠프2006/화요일/tar
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:07
Processing time 0.0207 sec