From cf134d36d76bd7f7bdd7eb838409f85c4d9c5a79 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 3 Jun 2014 13:13:58 +0000 Subject: [PATCH] EgtGeneral 1.5f1 : - agg. funzioni sui file (Exists e MatchExt). --- EgtGeneral.rc | Bin 11630 -> 11630 bytes EgtGeneral.vcxproj | 1 + EgtGeneral.vcxproj.filters | 3 +++ FileUtils.cpp | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+) diff --git a/EgtGeneral.rc b/EgtGeneral.rc index 0f87376afa7b10efa2c22f98b32ef99774f56c06..8a6bbefda7d8408c1ac8b863441b73d1d5a0a9aa 100644 GIT binary patch delta 110 zcmaDC^)70|CpK0y1|0^&&8x*uGfj?D3}8+JayBYvGH$Npc3_4}nlnQs(iu0W2s>ey N@R3H6KrwDFHvmVBAO-*c delta 110 zcmaDC^)70|CpK171|0^Y&8x*uGfj?D3}8+LayBYvGH$Npc3_4}nlnQs(iu0W2s>ey N@R3H6KrwDFHvmU;AO-*c diff --git a/EgtGeneral.vcxproj b/EgtGeneral.vcxproj index 3b31c03..f5164f1 100644 --- a/EgtGeneral.vcxproj +++ b/EgtGeneral.vcxproj @@ -185,6 +185,7 @@ copy $(TargetPath) \EgtProg\Dll64 + diff --git a/EgtGeneral.vcxproj.filters b/EgtGeneral.vcxproj.filters index a3bc3ae..5d38cef 100644 --- a/EgtGeneral.vcxproj.filters +++ b/EgtGeneral.vcxproj.filters @@ -60,6 +60,9 @@ File di intestazione + + File di intestazione + diff --git a/FileUtils.cpp b/FileUtils.cpp index 712ea33..0cb7b45 100644 --- a/FileUtils.cpp +++ b/FileUtils.cpp @@ -14,11 +14,32 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "\EgtDev\Include\EgnFileUtils.h" +#include "\EgtDev\Include\EgnStringUtils.h" #include "\EgtDev\Include\EgnStringConverter.h" #include 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)