]> OCCT Git - occt-wok.git/commitdiff
0024184: WOK is required to have the own analog of DirWalk method
authorkgv <kgv@opencascade.com>
Tue, 17 Sep 2013 12:42:04 +0000 (16:42 +0400)
committerbugmaster <bugmaster@opencascade.com>
Wed, 18 Sep 2013 07:41:55 +0000 (11:41 +0400)
13 files changed:
.gitignore
src/WOKAPI/WOKAPI_Command_Unit.cxx
src/WOKLibs/mscmd.cxx
src/WOKLibs/wokcmd.cxx
src/WOKLibs/woktoolscmd.cxx
src/WOKLibs/wokutilscmd.cxx
src/WOKNT/WOKNT_FindData.hxx
src/WOKNT/WOKNT_Handle.hxx
src/WOKNT/WOKNT_chmod.cxx
src/WOKNT/WOKNT_rm.cxx
src/WOKSH/EXTERNLIB
src/WOKSH/wokprocess.cxx
src/WOKSH/woksh.cxx

index 1b5852537c63432fb3153a7d5d593976c4c92f0b..94a3e48cd75f5a447b05e94a85e68161603863b2 100644 (file)
 /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
index d4190a1d5d3461288fa2e0bac4d7abd35e889edb..6497f900e4c8b2dfc6f22ece2d0107cb9a8d3746 100755 (executable)
 
 #include <WOKAPI_Command.jxx>
 
-#if defined( WNT ) && defined( _DEBUG )
-#include <OSD_Timer.hxx>
-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;
 }
 //=======================================================================
index ec0b7bbd1ac4b95c3f6cd657fdc152842c3ffdd9..feb854c7d672d5db5a8ac142003dba4131a4e107 100755 (executable)
@@ -22,9 +22,6 @@
 #include <MSAPI_MemberMet.hxx>
 
 #ifdef WNT
-# ifdef _DEBUG
-extern "C" void _debug_break ( char* );
-# endif  // _DEBUG
 # define MS_EXPORT __declspec( dllexport )
 #else
 # define MS_EXPORT
index ac09e4785abaed376308d010a8351a8cce7e6113..5bfaab4be0c65d0484a56469b846df1255832960 100755 (executable)
@@ -33,9 +33,6 @@
 #include <WOKTCL_TriggerHandler.hxx>
 
 #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();
index f30fdd6502c3cd62feaea0a7a5e4c5a3a6710386..265ed36d12d48da95642b30c1edd9a829eb23d3b 100755 (executable)
@@ -13,9 +13,6 @@
 #include <WOKTclTools_Package.hxx>
 
 #ifdef WNT
-# ifdef _DEBUG
-extern "C" void _debug_break ( char* );
-# endif  // _DEBUG
 # define WOKTOOLS_EXPORT __declspec( dllexport )
 #else
 # define WOKTOOLS_EXPORT
index 65c5934a5538099462b0dfc29ecdaf0b1f6069f4..49f53174b6dc0ccbe930d349f9b34a28959c7b54 100755 (executable)
@@ -11,9 +11,6 @@
 #include <WOKTclTools_Package.hxx>
 
 #ifdef WNT
-# ifdef _DEBUG
-extern "C" void _debug_break ( char* );
-# endif  // _DEBUG
 # define WOKUTILS_EXPORT __declspec( dllexport )
 #else
 # define WOKUTILS_EXPORT
index 440ca4c500425c83a45b5d2025ea9af863767da5..ac86c90a3455362f7f9d5a3e916976060bc744f0 100755 (executable)
@@ -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
 
index b4bf39bfd774115be2e96be1f17c51e2e53835b2..2ddd9bba2433dd6fbeeca4c4a0231452d0ba0037 100755 (executable)
@@ -23,7 +23,6 @@ typedef HANDLE WOKNT_Handle ;
 # undef RemoveDirectory
 #endif  // CreateFile
 
-
 #else
 
 
index 0cfd6420216b6de5c19abeb3998d09cdab30dcc6..75f3b4259e3152f13ae3b20ec3011edf6fbeb69a 100755 (executable)
@@ -1,5 +1,6 @@
 #ifdef WNT
 #define EXPORT
+#include <WOKNT_FindData.hxx>
 #include <Standard_Stream.hxx>
 #include <stdlib.h>
 
index 9655295b0ba4b90f0f38c13b4d988b7d290733de..2ee203b93565776d6659170ed090f7e35baacde5 100755 (executable)
@@ -1,5 +1,6 @@
 #ifdef WNT
 #define EXPORT
+#include <WOKNT_FindData.hxx>
 #include <stdlib.h>
 #include <io.h>
 #include <sys/stat.h>
@@ -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
index 635ef8a4fbe9dc1b99f2e033e03245bf928eea23..878b0fef575b87422597e84bd518b2a603507787 100755 (executable)
@@ -2,4 +2,5 @@ TKAdvTools
 TKernel
 TKWOK
 TKWOKTcl
+CSF_TclLibs
 CSF_TclTkLibs
index 8f8fa97ef609ddb7b5a27e1727f76f29ecdc5bf9..802380b4524dc24cd38c49c6a1558208548c9433 100755 (executable)
@@ -40,9 +40,6 @@
 #include <WOKTCL_TriggerHandler.hxx>
 
 #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();
index df5b698b9bffe28e3e5e9f2eda8c8bb0d45590b5..912de228904c647fd6752382b9785291e3f961ad 100755 (executable)
@@ -57,9 +57,6 @@ int main(int argc, char **argv)
 #include <WOKTCL_TriggerHandler.hxx>
 
 #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())