EgtGeneral 1.5f1 :

- agg. funzioni sui file (Exists e MatchExt).
This commit is contained in:
Dario Sassi
2014-06-03 13:13:58 +00:00
parent 9aeb86804b
commit cf134d36d7
4 changed files with 38 additions and 0 deletions
+34
View File
@@ -14,11 +14,32 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "\EgtDev\Include\EgnFileUtils.h"
#include "\EgtDev\Include\EgnStringUtils.h"
#include "\EgtDev\Include\EgnStringConverter.h"
#include <io.h>
using namespace std ;
//----------------------------------------------------------------------------
bool
ExistsFile( const string& sFile)
{
// leggo gli attributi del file
DWORD dwAttr = ::GetFileAttributesW( stringtoW( sFile)) ;
// se non esiste
if ( dwAttr == INVALID_FILE_ATTRIBUTES ||
dwAttr == INVALID_FILE_SIZE)
return false ;
// se è un direttorio
if ( dwAttr & FILE_ATTRIBUTE_DIRECTORY)
return false ;
return true ;
}
//-----------------------------------------------------------------------------
bool
EraseFile( const string& sFile)
@@ -26,6 +47,19 @@ EraseFile( const string& sFile)
return ( ::DeleteFileW( stringtoW( sFile)) != 0) ;
}
//-----------------------------------------------------------------------------
bool
FileExtensionMatches( const string& sFile, const string& sExt)
{
string sFileTitle ;
string sFileExt ;
SplitLast( sFile, ".", sFileTitle, sFileExt) ;
ToUpper( sFileExt) ;
string sExtUp = sExt ;
ToUpper( sExtUp) ;
return ( sFileExt == sExtUp) ;
}
//-----------------------------------------------------------------------------
bool
EmptyDirectory( const string& sDir)