EgtGeneral 1.5f1 :
- agg. funzioni sui file (Exists e MatchExt).
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user