#pragma once

#include "Patch_Util.h"


DWORD GetFileSize( const char* szFileName )
{
	HANDLE hFile = CreateFile( szFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
						  NULL, OPEN_EXISTING, 0, 0 );
	if( INVALID_HANDLE_VALUE == hFile )
	{
		return 0;
	}

	DWORD dwFileSize = GetFileSize ( hFile, NULL );
	CloseHandle( hFile );

	return dwFileSize;
}

bool IsFileExist( const char* szFileName )
{
	HANDLE hFile = CreateFile( szFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
						  NULL, OPEN_EXISTING, 0, 0 );
	if( INVALID_HANDLE_VALUE == hFile )
	{
		return false;
	}

	CloseHandle( hFile );
	return true;
}

bool IsDirectoryExist( const char* szDirName )
{
	DWORD dwAttr = GetFileAttributes( szDirName );

	if( INVALID_FILE_ATTRIBUTES == dwAttr )
	{
		return false;
	}

	if( FILE_ATTRIBUTE_DIRECTORY & dwAttr )
	{
		return true;
	}

	return false;
}