diff --git a/CmdScanner.cpp b/CmdScanner.cpp
index 4123a67..a390ec5 100644
--- a/CmdScanner.cpp
+++ b/CmdScanner.cpp
@@ -34,7 +34,7 @@ CmdScanner::~CmdScanner( void)
//----------------------------------------------------------------------------
bool
-CmdScanner::Init( string sCmdFile)
+CmdScanner::Init( const string& sCmdFile)
{
// se già aperto, lo chiudo
Terminate() ;
diff --git a/CmdScanner.h b/CmdScanner.h
index 9be06da..d82b15a 100644
--- a/CmdScanner.h
+++ b/CmdScanner.h
@@ -22,12 +22,11 @@ class CmdScanner
public :
CmdScanner( void) ;
~CmdScanner( void) ;
- bool Init( std::string sCmdFile) ;
+ bool Init( const std::string& sCmdFile) ;
bool Terminate( void) ;
bool GetLine( std::string& sLine) ;
int GetCurrLineNbr( void) { return m_nLineNbr ; }
- const std::string& GetFilePath( void)
- { return m_sFName ; }
+ const std::string& GetFilePath( void) { return m_sFName ; }
private :
std::string m_sFName ;
diff --git a/EgtGeneral.rc b/EgtGeneral.rc
index 3e594b7..4194470 100644
Binary files a/EgtGeneral.rc and b/EgtGeneral.rc differ
diff --git a/EgtGeneral.vcxproj b/EgtGeneral.vcxproj
index 5007bdd..fcc7171 100644
--- a/EgtGeneral.vcxproj
+++ b/EgtGeneral.vcxproj
@@ -98,6 +98,7 @@ copy $(TargetPath) \EgtProg\Dll
+
@@ -121,6 +122,8 @@ copy $(TargetPath) \EgtProg\Dll
+
+
diff --git a/EgtGeneral.vcxproj.filters b/EgtGeneral.vcxproj.filters
index a765a72..ad44d9c 100644
--- a/EgtGeneral.vcxproj.filters
+++ b/EgtGeneral.vcxproj.filters
@@ -54,6 +54,9 @@
File di intestazione
+
+ File di intestazione
+
@@ -77,6 +80,12 @@
File di origine
+
+ File di origine
+
+
+ File di origine
+
diff --git a/FileCompare.cpp b/FileCompare.cpp
new file mode 100644
index 0000000..09554ca
--- /dev/null
+++ b/FileCompare.cpp
@@ -0,0 +1,86 @@
+//----------------------------------------------------------------------------
+// EgalTech 2013-2013
+//----------------------------------------------------------------------------
+// File : FileCompare.cpp Data : 11.12.13 Versione : 1.4a5
+// Contenuto : Funzioni per confronto tra due file (di testo).
+//
+//
+//
+// Modifiche : 11.12.13 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+//--------------------------- Include ----------------------------------------
+#include "stdafx.h"
+#include "/EgtDEv/Include/EgnFileCompare.h"
+#include "/EgtDEv/Include/EGnStringConverter.h"
+#include "/EgtDEv/Include/EGnScan.h"
+
+using namespace std ;
+
+//----------------------------------------------------------------------------
+bool
+TextFileCompare( const string& sFile1, const string& sFile2, const string& sRemIni, const string& sFileO)
+{
+ bool bOk1 ;
+ bool bOk2 ;
+ int nDiff ;
+ string sLine1 ;
+ string sLine2 ;
+ ofstream ofOut ;
+ Scanner scFile1 ;
+ Scanner scFile2 ;
+
+
+ // apro il file per le differenze in append
+ ofOut.open( stringtoW( sFileO), ios_base::out | ios_base::app) ;
+ if ( ! ofOut.good())
+ return false ;
+
+ // emetto intestazione differenze
+ ofOut << "Compare " << sFile1 << " to " << sFile2 << " :" << endl ;
+
+ // apro il primo file
+ if ( ! scFile1.Init( sFile1, sRemIni.c_str())) {
+ ofOut << " Missing first file !!!" << endl ;
+ ofOut.close() ;
+ return false ;
+ }
+
+ // apro il secondo file
+ if ( ! scFile2.Init( sFile2, sRemIni.c_str())) {
+ ofOut << " Missing second file !!!" << endl ;
+ ofOut.close() ;
+ return false ;
+ }
+
+ // ciclo sulle linee dei due file
+ nDiff = 0 ;
+ bOk1 = scFile1.GetLine( sLine1) ;
+ bOk2 = scFile2.GetLine( sLine2) ;
+ while ( bOk1 || bOk2) {
+ // se linee diverse
+ if ( sLine1.compare( sLine2) != 0) {
+ nDiff ++ ;
+ // emetto differenze
+ ofOut << " Diff :" << endl ;
+ ofOut << " F1(" << scFile1.GetCurrLineNbr() << "):" << sLine1 << endl ;
+ ofOut << " F2(" << scFile2.GetCurrLineNbr() << "):" << sLine2 << endl ;
+ }
+ // passo alle linee successive
+ bOk1 = scFile1.GetLine( sLine1) ;
+ bOk2 = scFile2.GetLine( sLine2) ;
+ }
+
+ // emetto riassunto differenze
+ if ( nDiff == 0)
+ ofOut << " Same content" << endl ;
+ else
+ ofOut << " Found " << nDiff << " differences !!!" << endl ;
+
+ // chiudo il file di uscita
+ ofOut.close() ;
+
+ return true ;
+}
diff --git a/FileUtils.cpp b/FileUtils.cpp
new file mode 100644
index 0000000..712ea33
--- /dev/null
+++ b/FileUtils.cpp
@@ -0,0 +1,55 @@
+//----------------------------------------------------------------------------
+// EgalTech 2013-2013
+//----------------------------------------------------------------------------
+// File : FileUtils.cpp Data : 11.12.13 Versione : 1.4a5
+// Contenuto : Funzioni di utilità sui file.
+//
+//
+//
+// Modifiche : 11.12.13 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+//--------------------------- Include ----------------------------------------
+#include "stdafx.h"
+#include "\EgtDev\Include\EgnFileUtils.h"
+#include "\EgtDev\Include\EgnStringConverter.h"
+#include
+
+using namespace std ;
+
+//-----------------------------------------------------------------------------
+bool
+EraseFile( const string& sFile)
+{
+ return ( ::DeleteFileW( stringtoW( sFile)) != 0) ;
+}
+
+//-----------------------------------------------------------------------------
+bool
+EmptyDirectory( const string& sDir)
+{
+ wstring sDirW ;
+ wstring sFileW ;
+ _wfinddata_t c_file ;
+ intptr_t hFile ;
+
+
+ sDirW = stringtoW( sDir) ;
+ sFileW = sDirW + L"\\*.*" ;
+
+ // ciclo su tutti i file del direttorio
+ if ( ( hFile = _wfindfirst( sFileW.c_str(), &c_file)) != -1L) {
+ do {
+ if ( c_file.attrib != _A_SUBDIR) {
+ sFileW = sDirW + L"\\" + c_file.name ;
+ ::DeleteFileW( sFileW.c_str()) ;
+ }
+ } while( _wfindnext( hFile, &c_file) == 0) ;
+ _findclose( hFile) ;
+ errno = 0 ;
+ }
+
+ return true ;
+}
\ No newline at end of file
diff --git a/Scan.cpp b/Scan.cpp
index a9366c0..adbcb33 100644
--- a/Scan.cpp
+++ b/Scan.cpp
@@ -22,49 +22,66 @@ using namespace std ;
//----------------------------------------------------------------------------
-CScan::CScan( void)
+Scanner::Scanner( void)
{
m_nLineNbr = 0 ;
- m_pInFile = NULL ;
}
//----------------------------------------------------------------------------
-CScan::~CScan( void)
+Scanner::~Scanner( void)
{
+ Terminate() ;
}
//----------------------------------------------------------------------------
bool
-CScan::Init( ifstream& InFile)
+Scanner::Init( const std::string& sFile, const char* szRemInit)
{
- // verifico che il file passato sia regolarmente aperto per lettura
- if ( ! InFile.is_open())
- return false ;
-
- // assegno il file
- m_pInFile = &InFile ;
+ // apertura del file di ingresso
+ m_InFile.open( stringtoW( sFile), ios::in) ;
// reset numero linea corrente
m_nLineNbr = 0 ;
- return ( ! m_pInFile->fail()) ;
+ // salvo path file
+ m_sFName = sFile ;
+
+ // assegno i caratteri di inizio commento
+ if ( szRemInit != NULL)
+ m_sRemInit = szRemInit ;
+ else
+ m_sRemInit = "//" ;
+
+ return ( ! m_InFile.fail()) ;
}
//----------------------------------------------------------------------------
bool
-CScan::GetLine( string& sLine)
+Scanner::Terminate( void)
{
- if ( m_pInFile == nullptr || ! m_pInFile->is_open())
+ if ( m_InFile.is_open())
+ m_InFile.close() ;
+
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+Scanner::GetLine( string& sLine)
+{
+ if ( ! m_InFile.is_open())
return false ;
do {
- if ( ! getline( *m_pInFile, sLine))
+ if ( ! getline( m_InFile, sLine)) {
+ sLine = "" ;
return false ;
+ }
if ( m_nLineNbr == 0)
TrimUtf8Bom( sLine) ;
Trim( sLine) ;
m_nLineNbr ++ ;
- } while ( sLine.empty() || sLine.find( "//") == 0) ;
+ } while ( sLine.empty() || sLine.find( m_sRemInit) == 0) ;
return true ;
}