From 69de0d5f78a487977ef8c4e345233d01c02ba387 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 6 Jun 2014 08:52:17 +0000 Subject: [PATCH] EgtGeneral : - agg. funzione FindFirstFileEgt. --- FileUtils.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/FileUtils.cpp b/FileUtils.cpp index 0cb7b45..f877d24 100644 --- a/FileUtils.cpp +++ b/FileUtils.cpp @@ -60,6 +60,35 @@ FileExtensionMatches( const string& sFile, const string& sExt) return ( sFileExt == sExtUp) ; } +//----------------------------------------------------------------------------- +bool +FindFirstFileEgt( const string& sFileSpec, string& sFileName) +{ + wstring sFileSpecW ; + wstring sFileW ; + _wfinddata_t c_file ; + intptr_t hFile ; + + + sFileSpecW = stringtoW( sFileSpec) ; + + // cerco il primo file che soddisfa le specifiche + if ( ( hFile = _wfindfirst( sFileSpecW.c_str(), &c_file)) != -1L) { + do { + if ( c_file.attrib != _A_SUBDIR) { + sFileName = LPSTR( WtoA( c_file.name)) ; + _findclose( hFile) ; + errno = 0 ; + return true ; + } + } while( _wfindnext( hFile, &c_file) == 0) ; + _findclose( hFile) ; + errno = 0 ; + } + + return false ; +} + //----------------------------------------------------------------------------- bool EmptyDirectory( const string& sDir) @@ -86,4 +115,4 @@ EmptyDirectory( const string& sDir) } return true ; -} \ No newline at end of file +}