From a8d141b9780c14bbd3bf16f780071e70429f8ae6 Mon Sep 17 00:00:00 2001 From: kgv Date: Tue, 17 Sep 2013 16:42:04 +0400 Subject: [PATCH] 0024184: WOK is required to have the own analog of DirWalk method --- .gitignore | 13 ++++ src/WOKAPI/WOKAPI_Command_Unit.cxx | 18 +----- src/WOKLibs/mscmd.cxx | 3 - src/WOKLibs/wokcmd.cxx | 7 --- src/WOKLibs/woktoolscmd.cxx | 3 - src/WOKLibs/wokutilscmd.cxx | 3 - src/WOKNT/WOKNT_FindData.hxx | 7 ++- src/WOKNT/WOKNT_Handle.hxx | 1 - src/WOKNT/WOKNT_chmod.cxx | 1 + src/WOKNT/WOKNT_rm.cxx | 99 +++++++++++++++++++++++++++++- src/WOKSH/EXTERNLIB | 1 + src/WOKSH/wokprocess.cxx | 7 --- src/WOKSH/woksh.cxx | 7 --- 13 files changed, 119 insertions(+), 51 deletions(-) diff --git a/.gitignore b/.gitignore index 1b58525..94a3e48 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,19 @@ /win32 /win64 +# project files and artifacts +/adm/msvc +/adm/wnt +/adm/lin +/adm/mac +/adm/make +/adm/cmake +*.vcproj*user +*.csproj*user +*.ncb +*.suo +*.sdf + # /adm/ /adm/win32 /adm/win64 diff --git a/src/WOKAPI/WOKAPI_Command_Unit.cxx b/src/WOKAPI/WOKAPI_Command_Unit.cxx index d4190a1..6497f90 100755 --- a/src/WOKAPI/WOKAPI_Command_Unit.cxx +++ b/src/WOKAPI/WOKAPI_Command_Unit.cxx @@ -32,11 +32,6 @@ #include -#if defined( WNT ) && defined( _DEBUG ) -#include -extern "C" void _debug_break ( char* ); -#endif // WNT && _DEBUG - //======================================================================= void WOKAPI_UnitBuild_Usage(char *cmd) { @@ -541,11 +536,6 @@ Standard_Integer WOKAPI_Command::UnitMake(const WOKAPI_Session& asession, const Standard_Integer argc, const WOKTools_ArgTable& argv, WOKTools_Return& returns) { -#if defined( WNT ) && defined( _DEBUG ) - _debug_break ( "WOKAPI_Command :: UnitMake" ); - OSD_Timer t; - t.Start (); -#endif // WNT && _DEBUG WOKTools_Options opts(argc, argv, "s:e:u:o:t:fhSL", WOKAPI_UnitMake_Usage, "hfS"); Standard_Boolean force = Standard_False; Standard_Boolean hasonly = Standard_False; @@ -721,13 +711,7 @@ Standard_Integer WOKAPI_Command::UnitMake(const WOKAPI_Session& asession, } } - - - // -#if defined( WNT ) && defined( _DEBUG ) - t.Show (); -#endif // WNT && _DEBUG - + return status; } //======================================================================= diff --git a/src/WOKLibs/mscmd.cxx b/src/WOKLibs/mscmd.cxx index ec0b7bb..feb854c 100755 --- a/src/WOKLibs/mscmd.cxx +++ b/src/WOKLibs/mscmd.cxx @@ -22,9 +22,6 @@ #include #ifdef WNT -# ifdef _DEBUG -extern "C" void _debug_break ( char* ); -# endif // _DEBUG # define MS_EXPORT __declspec( dllexport ) #else # define MS_EXPORT diff --git a/src/WOKLibs/wokcmd.cxx b/src/WOKLibs/wokcmd.cxx index ac09e47..5bfaab4 100755 --- a/src/WOKLibs/wokcmd.cxx +++ b/src/WOKLibs/wokcmd.cxx @@ -33,9 +33,6 @@ #include #ifdef WNT -# ifdef _DEBUG -extern "C" void _debug_break ( char* ); -# endif // _DEBUG # define WOK_EXPORT __declspec( dllexport ) #else # define WOK_EXPORT @@ -51,10 +48,6 @@ void Wok_ExitHandler(void *) int Wok_Init(WOKTclTools_PInterp interp) { -#if defined( WNT ) && defined( _DEBUG ) - _debug_break ( "Wok_Init" ); -#endif // WNT && _DEBUG - OSD::SetSignal(); //==== Armed the signals. ============= Handle(WOKTclTools_Interpretor)& CurrentInterp = WOKTclTools_Interpretor::Current(); diff --git a/src/WOKLibs/woktoolscmd.cxx b/src/WOKLibs/woktoolscmd.cxx index f30fdd6..265ed36 100755 --- a/src/WOKLibs/woktoolscmd.cxx +++ b/src/WOKLibs/woktoolscmd.cxx @@ -13,9 +13,6 @@ #include #ifdef WNT -# ifdef _DEBUG -extern "C" void _debug_break ( char* ); -# endif // _DEBUG # define WOKTOOLS_EXPORT __declspec( dllexport ) #else # define WOKTOOLS_EXPORT diff --git a/src/WOKLibs/wokutilscmd.cxx b/src/WOKLibs/wokutilscmd.cxx index 65c5934..49f5317 100755 --- a/src/WOKLibs/wokutilscmd.cxx +++ b/src/WOKLibs/wokutilscmd.cxx @@ -11,9 +11,6 @@ #include #ifdef WNT -# ifdef _DEBUG -extern "C" void _debug_break ( char* ); -# endif // _DEBUG # define WOKUTILS_EXPORT __declspec( dllexport ) #else # define WOKUTILS_EXPORT diff --git a/src/WOKNT/WOKNT_FindData.hxx b/src/WOKNT/WOKNT_FindData.hxx index 440ca4c..ac86c90 100755 --- a/src/WOKNT/WOKNT_FindData.hxx +++ b/src/WOKNT/WOKNT_FindData.hxx @@ -23,8 +23,11 @@ typedef WIN32_FIND_DATA WOKNT_FindData; # undef RemoveDirectory #endif // CreateFile - - +extern BOOL DirWalk (LPCTSTR theDirName, + LPCTSTR theWildCard, + BOOL (*theFunc )(LPCTSTR , BOOL , void* ), + BOOL theRecurse, + void* theClientData); #else diff --git a/src/WOKNT/WOKNT_Handle.hxx b/src/WOKNT/WOKNT_Handle.hxx index b4bf39b..2ddd9bb 100755 --- a/src/WOKNT/WOKNT_Handle.hxx +++ b/src/WOKNT/WOKNT_Handle.hxx @@ -23,7 +23,6 @@ typedef HANDLE WOKNT_Handle ; # undef RemoveDirectory #endif // CreateFile - #else diff --git a/src/WOKNT/WOKNT_chmod.cxx b/src/WOKNT/WOKNT_chmod.cxx index 0cfd642..75f3b42 100755 --- a/src/WOKNT/WOKNT_chmod.cxx +++ b/src/WOKNT/WOKNT_chmod.cxx @@ -1,5 +1,6 @@ #ifdef WNT #define EXPORT +#include #include #include diff --git a/src/WOKNT/WOKNT_rm.cxx b/src/WOKNT/WOKNT_rm.cxx index 9655295..2ee203b 100755 --- a/src/WOKNT/WOKNT_rm.cxx +++ b/src/WOKNT/WOKNT_rm.cxx @@ -1,5 +1,6 @@ #ifdef WNT #define EXPORT +#include #include #include #include @@ -139,7 +140,7 @@ retry: else if ( pData -> fRecurse ) { cerr << fileName << endl; - status = RemoveDirectory ( fileName ); + status = RemoveDirectoryA ( fileName ); } @@ -196,4 +197,100 @@ static void _print_error ( LPCTSTR fName ) { cerr << "wokRM: could not remove " << fName << " - " << buffer << endl << flush; } // end _set_error + +BOOL DirWalk (LPCTSTR theDirName, + LPCTSTR theWildCard, + BOOL (*theFunc )(LPCTSTR , BOOL , void* ), + BOOL theRecurse, + void* theClientData) +{ + HANDLE aHeap = GetProcessHeap(); + PWIN32_FIND_DATA aFindData = (PWIN32_FIND_DATA )HeapAlloc (aHeap, 0, sizeof(WIN32_FIND_DATA)); + if (aFindData == NULL) + { + return FALSE; + } + + LPTSTR aName = (LPTSTR )HeapAlloc (aHeap, 0, lstrlen (theDirName) + lstrlen (theWildCard) + sizeof(TEXT('\x00'))); + if (aName == NULL) + { + HeapFree (aHeap, 0, aFindData); + return FALSE; + } + lstrcpy (aName, theDirName); + lstrcat (aName, theWildCard); + + LPTSTR aFullName = NULL; + BOOL aRetVal = TRUE; + HANDLE hFindFile = FindFirstFile (aName, aFindData); + for (BOOL hasNext = hFindFile != INVALID_HANDLE_VALUE; hasNext; hasNext = FindNextFile (hFindFile, aFindData)) + { + if (aFindData->cFileName[0] != TEXT('.') || + aFindData->cFileName[0] != TEXT('.') && + aFindData->cFileName[1] != TEXT('.')) + { + aFullName = (LPTSTR )HeapAlloc (aHeap, 0, + lstrlen (theDirName) + lstrlen (aFindData->cFileName) + + sizeof(TEXT('/')) + sizeof(TEXT('\x00'))); + if (aFullName == NULL) + { + aRetVal = FALSE; + break; + } + } + + lstrcpy (aFullName, theDirName); + lstrcat (aFullName, aFindData->cFileName); + if (aFindData->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY + && theRecurse) + { + lstrcat (aFullName, TEXT("/")); + if (!DirWalk (aFullName, theWildCard, theFunc, theRecurse, theClientData)) + { + aRetVal = FALSE; + } + } + else if (!theFunc (aFullName, aFindData->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? TRUE : FALSE, theClientData)) + { + aRetVal = FALSE; + } + + HeapFree (aHeap, 0, aFullName); + aFullName = NULL; + } + if (hFindFile != INVALID_HANDLE_VALUE) + { + FindClose (hFindFile); + } + + if (theRecurse) + { + LPTSTR aTmp = NULL; + int aLen = lstrlen (theDirName) - 1; + if (aLen > 0 + && theDirName[aLen] == TEXT('/')) + { + aTmp = (LPTSTR )HeapAlloc (aHeap, 0, aLen + 2); + if (aTmp != NULL) + { + lstrcpy (aTmp, theDirName); + aTmp[aLen] = 0; + aRetVal = theFunc (aTmp != NULL ? aTmp : theDirName, TRUE, theClientData); + HeapFree (aHeap, 0, aTmp); + } + else + { + aRetVal = FALSE; + aLen = 0; + } + } + } + + if (aFullName != NULL) HeapFree (aHeap, 0, aFullName); + if (aName != NULL) HeapFree (aHeap, 0, aName ); + if (aFindData != NULL) HeapFree (aHeap, 0, aFindData); + + return aRetVal; +} + #endif diff --git a/src/WOKSH/EXTERNLIB b/src/WOKSH/EXTERNLIB index 635ef8a..878b0fe 100755 --- a/src/WOKSH/EXTERNLIB +++ b/src/WOKSH/EXTERNLIB @@ -2,4 +2,5 @@ TKAdvTools TKernel TKWOK TKWOKTcl +CSF_TclLibs CSF_TclTkLibs diff --git a/src/WOKSH/wokprocess.cxx b/src/WOKSH/wokprocess.cxx index 8f8fa97..802380b 100755 --- a/src/WOKSH/wokprocess.cxx +++ b/src/WOKSH/wokprocess.cxx @@ -40,9 +40,6 @@ #include #ifdef WNT -# ifdef _DEBUG -extern "C" void _debug_break ( char* ); -# endif // _DEBUG # define WOK_EXPORT __declspec( dllexport ) #else # define WOK_EXPORT @@ -59,10 +56,6 @@ void Wok_ExitHandler(void *) int main(int argc, char **argv) { -#if defined( WNT ) && defined( _DEBUG ) - _debug_break ( "main" ); -#endif // WNT && _DEBUG - Handle(WOKTclTools_Interpretor)& CurrentInterp = WOKTclTools_Interpretor::Current(); WOKTclTools_PInterp interp = Tcl_CreateInterp(); diff --git a/src/WOKSH/woksh.cxx b/src/WOKSH/woksh.cxx index df5b698..912de22 100755 --- a/src/WOKSH/woksh.cxx +++ b/src/WOKSH/woksh.cxx @@ -57,9 +57,6 @@ int main(int argc, char **argv) #include #ifdef WNT -# ifdef _DEBUG -extern "C" void _debug_break ( char* ); -# endif // _DEBUG # define WOK_EXPORT __declspec( dllexport ) #else # define WOK_EXPORT @@ -75,10 +72,6 @@ void Wok_ExitHandler(void *) int Wok_Init(WOKTclTools_PInterp interp) { -#if defined( WNT ) && defined( _DEBUG ) - _debug_break ( "Wok_Init" ); -#endif // WNT && _DEBUG - Handle(WOKTclTools_Interpretor)& CurrentInterp = WOKTclTools_Interpretor::Current(); if(WOKTclTools_Interpretor::Current().IsNull()) -- 2.39.5