// DDSHeader.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
//

#include "stdafx.h"

/*
void CPackToolDlgDlg::Recurse( CString perfolder )
{
	CString		str;
	CString		folder   = perfolder;

	folder += _T( "/*.*" );

	CFileFind finder;
	BOOL bWorking = finder.FindFile( folder );

	while( bWorking )
	{
		bWorking = finder.FindNextFile();

		if( finder.IsDots() )
			continue;

		CString path = finder.GetFilePath();
		if( finder.IsDirectory() )
			Recurse( path );
		else
			AddFileList(path.GetBuffer());

		Sleep( 1 );
	}
}
*/

int main(int argc, char* argv[])
{
	if(argc <= 1)
		return 0;

/*
    DWORD dwMagic;    
	dwMagic=MAKEFOURCC('D','D','S',' ');
	//dwMagic=0xffffffff;
	fwrite(&dwMagic,sizeof(dwMagic),1,fp);
*/
//	char ddsh[4] = { 0x44, 0x44, 0x53, 0x20 };

    DWORD dwMagic;    
	dwMagic=MAKEFOURCC(' ',' ',' ',' ');
//	dwMagic=MAKEFOURCC('D','D','S',' ');

	//헤더 수정부분
	for(int i = 1; i < argc; ++i)
	{
		char* file = argv[i];
		FILE* fp = fopen(file, "r+");

		if(fp == NULL)
			return 0;

		fseek(fp, 0, SEEK_CUR);
		fpos_t pos = 0;
		fgetpos( fp, &pos );

		if(fsetpos( fp, &pos ) == 0)
			fwrite(&dwMagic,sizeof(dwMagic),1,fp);
		else
			printf("file error\n");

		fgetpos( fp, &pos );
		fclose(fp);
	}

	return 0;
}

