Explorer; libede: Fixes to compile, warnings; fixed single window coming up when...
authorJerome St-Louis <jerome@ecere.com>
Mon, 7 Sep 2020 00:49:14 +0000 (20:49 -0400)
committerJerome St-Louis <jerome@ecere.com>
Mon, 7 Sep 2020 00:49:14 +0000 (20:49 -0400)
explorer/explorer.epj
explorer/src/DeleteBox.ec
explorer/src/Explorer.ec
explorer/src/ExplorerWindow.ec
explorer/src/Finder.ec
libede/src/CreateNewFileDialog.ec
libede/src/FileSystemBox.ec
libede/src/FileSystemCache.ec
libede/src/FileSystemIterator.ec
libede/src/FileSystemSearch.ec

index 804866e..39cea87 100644 (file)
          "Folder" : "extern",
          "Files" : [
             {
-               "FileName" : "../../../sdk/extras/gui/controls/ToolBar.ec",
+               "FileName" : "$(ECERE_SDK_SRC)/extras/gui/controls/ToolBar.ec",
                "Options" : {
                   "ExcludeFromBuild" : true
                }
             },
-            "../../../sdk/extras/gui/controls/SearchBox.ec"
+            "$(ECERE_SDK_SRC)/extras/gui/controls/SearchBox.ec"
          ],
          "Configurations" : [
             {
index d9c2d08..e91f52c 100644 (file)
@@ -14,7 +14,7 @@ public:
    ListBox source;
 
 private:
-   
+
    ListBox list
    {
       parent = this, borderStyle = deep, hasVertScroll = true, hasHorzScroll = true;
@@ -73,7 +73,7 @@ private:
             }
             // what if a child of some parent was added before that parent, should check to remove
             // or is it imposible to get the backwards order from GetMultiSelection
-            
+
             //for(branch = (ExplorerFileBranch)row.tag; branch; branch = branch.parent)
             //   branches.Add(branch);
          }
@@ -94,11 +94,11 @@ private:
                parent.DuplicateChildren(true, true, root, list);
             }
          }
-         
+
          */
          /*
          copies.count = branches.count;
-         
+
          {
             bool added = true;
             uint b;
index 134b675..6b9f872 100644 (file)
@@ -46,12 +46,13 @@ class Explorer : GuiApplication
             openArgsStartAt = 2;
          else if(!strcmpi(argv[1], "find") && argc > 2)
          {
-            char * unquoted;
             if(argv[2][0] == '\"')
-               StripQuotes(argv[2], unquoted);
+            {
+               findWhat = new char[strlen(argv[2])+1];
+               StripQuotes(argv[2], findWhat);
+            }
             else
-               unquoted = argv[2];
-            findWhat = CopyString(unquoted);
+               findWhat = CopyString(argv[2]);
             if(argc > 3)
             {
                if(!strcmpi(argv[3], "in") && argc > 4)
@@ -61,7 +62,7 @@ class Explorer : GuiApplication
             }
             else
                searchPath = ""; // same
-         } 
+         }
          else if(!strcmpi(argv[1], "search") && argc > 2)
             searchPath = argv[2];
          else if(!strcmpi(argv[1], "compare") && argc > 2)
@@ -71,11 +72,11 @@ class Explorer : GuiApplication
             if(argc == 3)
             {
                goPath = ""; // current dir
-               comparedPaths.Add(goPath);
+               comparedPaths.Add(CopyString((const char *)goPath));  // TODO: Review whether this gets freed?
             }
             for(c = 2; c < argc; c++)
             {
-               char * s;
+               const char * s;
                goPath = argv[c];
                s = goPath;
                if(s)
@@ -106,6 +107,8 @@ class Explorer : GuiApplication
                explorerWnd.Create();
                explorerWnd.location = goPath;//explorerWnd.GoTo(goPath, false, false);
             }
+            if(openArgsStartAt == -1)
+               break;
          }
       }
       else if(searchPath)
@@ -121,8 +124,14 @@ class Explorer : GuiApplication
          explorerWnd.Create();
          explorerWnd.view.columnsCompareStyle = true;
          explorerWnd.comparedLocations = comparedPaths;
+         comparedPaths = null;
          // delete comparedPaths;
       }
+      if(comparedPaths)
+      {
+         comparedPaths.Free();
+         delete comparedPaths;
+      }
       return true;
    }
 }
@@ -131,17 +140,20 @@ struct QuickPathTool
 {
    char path[MAX_LOCATION];
 
-   property char * 
+   property const char *
    {
       set
       {
-         char * unquoted;
          GetWorkingDir(path, MAX_LOCATION);
          if(value[0] == '\"')
+         {
+            char * unquoted = new char[strlen(value) + 1];
             StripQuotes(value, unquoted);
+            PathCat(path, unquoted);
+            delete unquoted;
+         }
          else
-            unquoted = value;
-         PathCat(path, unquoted);
+            PathCat(path, value);
          if(!FileExists(path))
          {
             // this incomplete functionality is not quite at it's place in this class
@@ -152,7 +164,7 @@ struct QuickPathTool
                StripLastDirectory(path, path);
                if(FileExists(path))
                {
-                  // TODO: message location does not exist, 
+                  // TODO: message location does not exist,
                   //       this higher location exists though
                   //       go there?
                   break;
@@ -160,7 +172,7 @@ struct QuickPathTool
             }
             if(!len)
             {
-               // TODO: message location does not exist, 
+               // TODO: message location does not exist,
                //       unable to select alternate location
             }
             path[0] = '\0';
index f1c0a2d..d22c0d2 100644 (file)
@@ -66,7 +66,7 @@ enum Icon
    searchInSubDirs, searchStart, searchStop,
    hasHeader
 };
-static char * iconNames[Icon::enumSize] =
+static const char * iconNames[Icon::enumSize] =
 {
    "<:ecere>emblems/unreadable.png",         /* missing */
 
@@ -152,7 +152,7 @@ class ExplorerWindow : Window
 
    int treeSplit;
    int searchSplit;
-   
+
    ExplorerToolId lastViewId;
 */
 
@@ -162,7 +162,7 @@ class ExplorerWindow : Window
 
 
    menu = Menu { };
-   
+
    Menu fileMenu { menu, "File", f };
    Menu windowMenu { menu, "Window", w };
       MenuItem itemNewWindow { windowMenu, "New Window", n, NotifySelect = NewWindow_NotifySelect };
@@ -445,7 +445,7 @@ class ExplorerWindow : Window
    IconToolButton goUp { toolBar, this, icon = goUp, hotKey = { up, alt = true }, toolTip = "Go to Parent Folder";
       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
       {
-         char * path = view.path;
+         const char * path = view.path;
          char * newPath = new char[strlen(path)+1];
          StripLastDirectory(path, newPath);
          if(!newPath[0])
@@ -881,6 +881,7 @@ class ExplorerWindow : Window
       {
          //((FileSystemCacheIterator)fileSystemIterator).cache = testCache;
          //((FileSystemIterator)fileSystemIterator)
+         return true;
       }
 
       bool NotifyNodeOpen(FileSystemBox box, FileSystemBoxSelection selection)
@@ -931,7 +932,7 @@ class ExplorerWindow : Window
 
          //PrintLn(node.name);
          if(box.selection.nodes.count == 1)
-            itemString = node.name;
+            itemString = CopyString(node.name);
          else
             itemString = PrintString(box.selection.nodes.count, " items");
          text = PrintString("Open ", itemString);
@@ -1102,6 +1103,7 @@ class ExplorerWindow : Window
          if(CreateNewFileDialog { /*master = */ew/*, parent = parent*/, currentDirectory = selection ? ew.view.selection.node.path : ew.view.path }.Modal() == ok )
             ew.Refresh();
       }
+      return true;
    }
 
    //void NewFolder()
@@ -1113,10 +1115,11 @@ class ExplorerWindow : Window
          if(CreateDirectoryDialog { /*master = */ew/*, parent = parent*/, currentDirectory = selection ? ew.view.selection.node.path : ew.view.path }.Modal() == ok )
             ew.Refresh();
       }
+      return true;
    }
 
    //void GoTo(char * location/*, bool viewIsAtLocation, bool treeIsAtLocation*/)
-   property char * location
+   property const char * location
    {
       set
       {
@@ -1317,7 +1320,7 @@ class ExplorerWindow : Window
       }
       return true;
    }*/
-   
+
    /*bool ViewNotifyItemOpen(ExplorerView view, ExplorerFileItem item)
    {
       ExplorerFileBranch branch = tree.branch;
@@ -1326,14 +1329,14 @@ class ExplorerWindow : Window
          if(item.type.isFolderType)
          {
             ExplorerFileBranch child;
-            
+
             if(!branch.loaded || !branch.childrenLoaded)
                BranchLoad(branch, tree.tree);
 
             for(child = branch.children.first; child; child = child.next)
                if(!strcmp(child.name, item.name))
                   break;
-            
+
             if(child)
             {
                if(branch.row.collapsed)
@@ -1409,7 +1412,7 @@ class ExplorerWindow : Window
          NotifyItemOpen = ViewNotifyItemOpen;
       };
       lastViewId = viewList;
-      
+
       tree.Load();
       view.Load(tree.root);
    }*/
index c65367f..42e2d58 100644 (file)
@@ -31,7 +31,7 @@ public:
    void SearchStart()
    {
       char text[2048];
-      
+
       searchThread.active = true;
 
       searchThread.optionSubdirs = options.subdirs.checked;
@@ -45,7 +45,7 @@ public:
       strcpy(searchThread.location, location.GetText());
       strcpy(searchThread.nameSearch, findName.GetText());
       strcpy(searchThread.contentSearch, findTextContent.GetText());
-      
+
       actions.startStop.text = "Stop Search";
       actions.clear.disabled = false;
       view.results.Clear();
@@ -57,7 +57,7 @@ public:
       view.browser.text = "Browser";
       sprintf(text, "Search Results (Searching %s)", location.GetText());
       view.results.text = text;
-      
+
       searchThread.Create();
    }
 
@@ -104,7 +104,7 @@ public:
    void SearchTerminate()
    {
       char text[1024];
-      
+
       if(searchThread.terminate)
          sprintf(text, "Search Results (%d item(s) found), Search was aborted.", searchThread.matchCount);
       else
@@ -112,7 +112,7 @@ public:
       view.results.text = text;
       sprintf(text, "Browser (%d item(s) searched)", searchThread.count);
       view.browser.text = text;
-         
+
       actions.startStop.text = "Start Search";
    }
 
@@ -190,7 +190,7 @@ class ExplorerSearchView : ExplorerView
 
 class ExplorerSearchViewTree : ExplorerSearchView
 {
-   
+
    DataField resultsFieldPath { "char *" };
 
    ListBox results
@@ -252,9 +252,9 @@ class ExplorerSearchViewTree : ExplorerSearchView
          {
             OldList selection;
             Link item;
-            
+
             listBox.GetMultiSelection(selection);
-            
+
             for(item = selection.first; item; item = item.next)
             {
                char path[MAX_LOCATION];
@@ -274,7 +274,7 @@ class ExplorerSearchViewTree : ExplorerSearchView
    }
 
    bool Lists_NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
-   {  
+   {
       if(listBox.currentRow)
       {
          char path[MAX_LOCATION];
index 49755a0..0c793cb 100644 (file)
@@ -10,7 +10,7 @@ public class CreateNewFileDialog : Window
 
 public:
 
-   property char * currentDirectory
+   property const char * currentDirectory
    {
       set
       {
@@ -18,7 +18,7 @@ public:
          PathCat(currentDirectory, value);
          FileFixCase(currentDirectory);
       }
-      get { return (char *)currentDirectory; }
+      get { return currentDirectory; }
    };
 
 private:
@@ -27,7 +27,7 @@ private:
 
    CreateNewFileDialog()
    {
-      FileNameType c;
+      //FileNameType c;
 
       GetWorkingDir(currentDirectory, MAX_DIRECTORY);
       FileFixCase(currentDirectory);
index 82a7abd..36edd05 100644 (file)
@@ -3,22 +3,22 @@ import "FileSystemCache"
 
 #ifdef __WIN32__
 static char * rootName = "Entire Computer";
-static char * msNetwork = "Microsoft Windows Network";
+static const char * msNetwork = "Microsoft Windows Network";
 #else
-static char * rootName = "File System";
+static const char * rootName = "File System";
 #endif
 
 private:
 define guiApp = (GuiApplication)((__thisModule).application);
 define selectionColor = guiApp.currentSkin.selectionColor; //Color { 10, 36, 106 };
 
-void MessageBoxTodo(char * message)
+void MessageBoxTodo(const char * message)
 {
    PrintLn("MessageBoxTodo(char * message) -- ", message);
    MessageBox { type = ok, text = "MessageBoxTodo(char * message)", contents = message }.Modal();
 }
 
-static char * fileIconNames[] =
+static const char * fileIconNames[] =
 {
    "<:ecere>mimeTypes/file.png",         /* none */
 
@@ -58,7 +58,7 @@ static char * fileIconNames[] =
 };
 
 define countOfCompIconNames = 6;
-static char * compIconNames[] =
+static const char * compIconNames[] =
 {
 /*
    "<:ede>a.png",
@@ -213,7 +213,7 @@ public:
    virtual bool Window::NotifyNodeMenu(FileSystemBox box, Menu menu, FileSystemBoxSelection selection);
    virtual bool Window::NotifyIteratorInit(FileSystemBox box, FileSystemIterator fileSystemIterator);
 
-   property char * path
+   property const char * path
    {
       set
       {
@@ -233,7 +233,11 @@ public:
    {
       set
       {
-         delete comparedPaths;
+         if(comparedPaths)
+         {
+            comparedPaths.Free();
+            delete comparedPaths;
+         }
          if(value && value.count)
             comparedPaths = value;
          if(locationBox)
@@ -334,7 +338,7 @@ public:
       delete map;
    }
 
-   FileSystemNode SelectLocation(char * location)
+   FileSystemNode SelectLocation(const char * location)
    {
       int c;
       char * temp;
@@ -355,7 +359,7 @@ public:
 
       for(c = steps.count - 1; c >= 0; c--)
       {
-         char * t = steps[c];
+         //char * t = steps[c];
          node = Find(steps[c], node);
          if(!node)
             break;
@@ -418,6 +422,7 @@ public:
    bool MenuOpen(MenuItem selection, Modifiers mods)
    {
       OpenNode();
+      return true;
    }
 
    bool MenuReplaceListItemByContainingDir(MenuItem selection, Modifiers mods)
@@ -482,6 +487,11 @@ private:
 
    ~FileSystemBox()
    {
+      if(comparedPaths)
+      {
+         comparedPaths.Free();
+         delete comparedPaths;
+      }
       delete extensions;
       delete path;
    }
@@ -699,7 +709,7 @@ private:
       {
          if(row)
          {
-            FileSystemNode node = (FileSystemNode)row.tag;
+            //FileSystemNode node = (FileSystemNode)row.tag;
          }
          return true;
       }
@@ -708,7 +718,7 @@ private:
       {
          if(row)
          {
-            FileSystemNode node = (FileSystemNode)row.tag;
+            //FileSystemNode node = (FileSystemNode)row.tag;
          }
          return true;
       }
@@ -717,7 +727,7 @@ private:
       {
          if(row)
          {
-            FileSystemNode node = (FileSystemNode)row.tag;
+            //FileSystemNode node = (FileSystemNode)row.tag;
          }
          return true;
       }
@@ -731,20 +741,20 @@ private:
 
       bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
       {
-         bool result;
+         //bool result = false;
          if((SmartKey)key == enter)
-            result = OpenNode();
+            /*result = */OpenNode();
          #if 0
          else if((SmartKey)key == f2)
-            result = RenameNode();
+            /*result = */RenameNode();
          #endif
          else if((SmartKey)key == f2)
          {
             FileSystemNode node = selection.node;
             node.row.Edit(nameField);
          }
-         else
-            result = true;
+         //else
+            //result = true;
          return true;
       }
    };
@@ -777,12 +787,12 @@ private:
             int wWnd = fsb.show.clientSize.w;
             int hWnd = fsb.show.clientSize.h;
 
-            int wList = 0;//fsb.list.size.w + fsb.split.size.w;
+            //int wList = 0;//fsb.list.size.w + fsb.split.size.w;
 
-            float scale = Min((float)(wWnd - 10) / wBmp, (float)(hWnd - 10) / hBmp);
+            //float scale = Min((float)(wWnd - 10) / wBmp, (float)(hWnd - 10) / hBmp);
 
-            int wDraw = (int)(wBmp * scale);
-            int hDraw = (int)(hBmp * scale);
+            //int wDraw = (int)(wBmp * scale);
+            //int hDraw = (int)(hBmp * scale);
 
       #ifndef __linux__
             surface.Filter(fsb.bitmap, (wWnd - wDraw) / 2, (hWnd - hDraw) / 2, 0, 0, wDraw, hDraw, wBmp, hBmp);
@@ -797,7 +807,7 @@ private:
             surface.Area(0, 0, fsb.clientSize.w - 1, fsb.clientSize.h - 1);
          }
       }
-   }
+   };
 
    bool OpenNode()
    {
@@ -967,9 +977,9 @@ private:
    {
       bool isRoot = !strcmp(path, "/");
       char name[MAX_LOCATION];
-      FileSystemNode parent;
-      FileSystemNode node;
-      FileListing listing { path, extensions = extensions };
+      //FileSystemNode parent;
+      //FileSystemNode node;
+      //FileListing listing { path, extensions = extensions };
 
       if(!isRoot)
          GetLastDirectory(path, name);
@@ -1105,7 +1115,7 @@ private:
       }
    }
 
-   bool ListIterator_OnObject(char * name, char * path, FileStats stats, bool isRootObject)
+   bool ListIterator_OnObject(const char * name, const char * path, FileStats stats, bool isRootObject)
    {
       ProcessListItem(name, path, stats, false);
       return false;
@@ -1113,7 +1123,7 @@ private:
 
    //void ListIterator_OnLeavingDirectory(char * path) { }
 
-   void ProcessListItem(char * name, char * path, FileStats stats, bool isListItem)
+   void ProcessListItem(const char * name, const char * path, FileStats stats, bool isListItem)
    {
       if((!bits.foldersOnly && !bits.filesOnly) || (bits.foldersOnly && stats.attribs.isDirectory) || (bits.filesOnly && stats.attribs.isFile))
       {
@@ -1192,17 +1202,21 @@ private:
          FileListing listing { path, extensions = extensions };
          while(listing.Find())
          {
-            char * test;
+            //char * test;
             FileSystemNode child = null;
             if((!bits.foldersOnly && !bits.filesOnly) ||
                (bits.foldersOnly && listing.stats.attribs.isDirectory) ||
                (bits.filesOnly && listing.stats.attribs.isFile))
                child = MakeAndAddToTreeFileSystemNodeFromFileListing(listing, parent);
             if(child)
+            {
                added = true;
-            test = child.name;
-            if(!test)
-               PrintLn("error");
+               /*
+               test = child.name;
+               if(!test)
+                  PrintLn("error");
+               */
+            }
          }
          if(!added)
             added = true;
@@ -1212,7 +1226,7 @@ private:
 
    void LoadComparedList()
    {
-      int c, cmp/*, smallest*/, icon;//, equalCount;
+      int c/*, cmp*/ /*, smallest*/, icon;//, equalCount;
       int count = comparedPaths ? comparedPaths.count : 0;
       //bool allDone = false;
       bool not;
@@ -1456,7 +1470,7 @@ private:
    void AddNode(FileSystemNode node)
    {
       DataRow row = list.AddRow();
-      row.tag = (int)node;
+      row.tag = (intptr)node;
       node.row = row;
       incref node;
       row.SetData(nameField, node);
@@ -1488,7 +1502,7 @@ private:
          (bits.filesOnly && listing.stats.attribs.isFile)))*/
       {
          bool textFileLinesStyle = false;
-         char * test = listing.name;
+         const char * test = listing.name;
          if(!test)
             PrintLn("error");
          result = MakeFileSystemNode(listing.stats, listing.name, listing.path, false, bits.previewPictures, false, displaySystem);
@@ -1525,7 +1539,7 @@ private:
          node.indent = addTo.indent + 1;
          addTo.children.Add(node);
       }
-      row.tag = (int)node;
+      row.tag = (intptr)node;
       node.row = row;
       row.SetData(null, node);
       if(bits.pathColumn)
@@ -2677,7 +2691,7 @@ private:
    }
 
 public:
-   /*//LinkElement<FileSystemNode> link;
+   /* LinkElement<FileSystemNode> link;
    FileSystemNode parent;
 
    FileSystemNodeType type;
@@ -2690,12 +2704,12 @@ public:
 
    property bool isListItem { set { bits.isListItem = value; } get { return bits.isListItem; } };
 
-   property char * path
+   property const char * path
    {
       set { delete path; if(value && value[0]) path = CopyString(value); }
       get { return path; } isset { return path && path[0]; }
    }
-   property char * name
+   property const char * name
    {
       set { delete name; if(value && value[0]) name = CopyString(value); }
       get { return name; } isset { return name && name[0]; }
@@ -2705,12 +2719,12 @@ public:
       set { delete extension; if(value && value[0]) extension = CopyString(value); }
       get { return extension; } isset { return extension && extension[0]; }
    }
-   property char * label
+   property const char * label
    {
       set { delete label; if(value && value[0]) label = CopyString(value); }
       get { return label; } isset { return label && label[0]; }
    }
-   property char * info
+   property const char * info
    {
       set { delete info; if(value && value[0]) info = CopyString(value); }
       get { return info; } isset { return info && info[0]; }
@@ -2819,7 +2833,7 @@ public:
    void OnDisplay(Surface surface, int x, int y, int width, FileSystemBox fsb, Alignment alignment, DataDisplayFlags displayFlags)
    {
       //int indentSize = (displayFlags.dropBox) ? 0 : 10;
-      int indent = 16;
+      //int indent = 16;
       int xStart;
       int len;
       int w, h;
@@ -3097,7 +3111,7 @@ public:
    //}
 #endif
 
-   bool OnGetDataFromString(char * string)
+   bool OnGetDataFromString(const char * string)
    {
 #if 0
       if(string && *string)
@@ -3111,7 +3125,7 @@ public:
       return false;
    }
 
-   char * OnGetString(char * tempString, FileSystemToolWindow fileSysToolWnd, bool * needClass)
+   const char * OnGetString(char * tempString, void * unused /*FileSystemToolWindow fileSysToolWnd*/, bool * needClass)
    {
       return name ? name : "";
    }
@@ -3154,7 +3168,7 @@ FileSystemNode MakeFileSystemNode(
    const bool pathAddName,
    const bool previewPicture,
    const bool isListItem,
-   const DisplaySystem displaySystem)
+   /*const */DisplaySystem displaySystem)
 {
    int len = strlen(name);
    char info[MAX_LOCATION];
@@ -3215,8 +3229,8 @@ FileSystemNode MakeFileSystemNode(
 
    if(pathAddName)
    {
-      bool isFile = stats.attribs.isFile;
-      bool isFolder = stats.attribs.isDirectory;
+      //bool isFile = stats.attribs.isFile;
+      //bool isFolder = stats.attribs.isDirectory;
       char full[MAX_LOCATION];
       strcpy(full, path);
       PathCat(full, name);
@@ -3249,8 +3263,8 @@ FileSystemNode MakeComparedFileSystemNode(
    const bool previewPicture,
    const int cmpIcon,
    const bool cmpNot,
-   const Array<int> exists,
-   const DisplaySystem displaySystem)
+   /*const */Array<int> exists,
+   /*const */DisplaySystem displaySystem)
 {
    FileSystemNode node = MakeFileSystemNode(stats, name, path, pathAddName, previewPicture, false, displaySystem);
    if(node)
index 03920bd..89eeaa1 100644 (file)
@@ -132,16 +132,16 @@ public:
                iterateStartPath = true;
 
                // COMPILER TOFIX: this will not compile (error: method class must be derived from class) -- bool Whatever/*FileSystemCache*/::OnFolder(...)
-               bool /*FileSystemCache*/DummyFileSystemCacheWindow::OnObject(char * name, char * path, FileStats stats, bool isRootObject)
+               bool /*FileSystemCache*/DummyFileSystemCacheWindow::OnObject(const char * name, const char * path, FileStats stats, bool isRootObject)
                {
                   bool result = true;
                   FileSystemCache cache = this.cache;
-                  uint dev = stats.dev;
-                  uint inode = stats.inode;
+                  //uint dev = stats.dev;
+                  //uint inode = stats.inode;
                   char * p;
                   FSCacheObject parent = isRootObject ? null : cache.normalParentStack.lastIterator.data;
                   FSCacheObject o { parent, name = CopyString(isRootObject ? path : name), stats = stats };
-                  FileStats s;
+                  //FileStats s;
                   if(isRootObject)
                   {
                      // TODO see if we can find a parent for it
@@ -163,20 +163,22 @@ public:
                   }
                   cache.objects.Add(o);
 #if _DEBUG
+                  /*
                   if(cache.objects.count % 1000 == 0)
                      PrintLn(path, " ----- ", cache.objects.count / 1000, " --------- ", dev);
-                  FileGetStatsLink(path, s);
+                  */
+                  //FileGetStatsLink(path, s);
+                  /*
                   if(s.inode != inode)
                   {
                      PrintLn(s.inode);
                      PrintLn(inode);
-                     PrintLn("crap");
                   }
+                  */
                   p = o.GetPath();
                   if(strcmp(p, path))
                   {
                      int c;
-                     PrintLn("damn");
                      PrintLn(p);
                      for(c = 0; c < cache.normalParentStack.count; c++)
                      {
@@ -185,10 +187,10 @@ public:
                         PrintLn(p);
                      }
                      PrintLn(path);
-                     PrintLn("bad");
                   }
                   delete p;
 #endif
+                  /*
                   if(dev && inode && cache.bits.indexInodes)
                   {
                      FileSystemDeviceCache devCache = cache.deviceCaches[dev];
@@ -203,17 +205,18 @@ public:
                         inodes.Add(o);
                      }
                   }
+                  */
                   return result;
                }
 
-               void /*FileSystemCache*/DummyFileSystemCacheWindow::OnEnteringDirectory(char * path)
+               void /*FileSystemCache*/DummyFileSystemCacheWindow::OnEnteringDirectory(const char * path)
                {
                   FileSystemCache cache = this.cache;
                   FSCacheObject o = cache.objects.lastIterator.data;
                   cache.normalParentStack.Add(o);
                }
 
-               void /*FileSystemCache*/DummyFileSystemCacheWindow::OnLeavingDirectory(char * path)
+               void /*FileSystemCache*/DummyFileSystemCacheWindow::OnLeavingDirectory(const char * path)
                {
                   FileSystemCache cache = this.cache;
                   cache.normalParentStack.lastIterator.Remove();
@@ -310,8 +313,11 @@ public:
    void Special(char * path/*, Map<String, bool> linksPaths*//*Map<uint, Map<uint, bool>> devsInodesDone*/, DummyFileSystemCacheWindow dummyWindow)
    {
       FileSystemCacheIterator fsci { owner = dummyWindow, cache = this, iterateStartPath = true;
-         bool /*FileSystemCache*/DummyFileSystemCacheWindow::OnObject(char * name, char * path, FileStats stats, bool isRootObject)
+         bool /*FileSystemCache*/DummyFileSystemCacheWindow::OnObject(const char * name, const char * path,
+            FileStats stats, bool isRootObject)
          {
+                        /*
+
             uint dev = stats.dev;
             uint inode = stats.inode;
             FileSystemCache cache = this.cache;
@@ -353,6 +359,7 @@ public:
             }
             else
                PrintLn("no dev/inode");
+            */
             return true;
          }
       };
@@ -455,12 +462,12 @@ private:
    }
 }
 
-Array<String> GetPathDirNamesArray(char * path)
+Array<String> GetPathDirNamesArray(const char * path)
 {
    Array<String> names;
    if(path && path[0])
    {
-      char * p = path;
+      const char * p = path;
       char rest[MAX_LOCATION];
       char name[MAX_FILENAME];
       names = { };
index 6c2cab3..8561a54 100644 (file)
@@ -25,10 +25,10 @@ public:
       {
          char name[MAX_LOCATION] = "";
          FileStats stats;
-         if(followLinks)
+         //if(followLinks)
             FileGetStats(startPath, stats);
-         else
-            FileGetStatsLink(startPath, stats);
+         /*else
+            FileGetStatsLink(startPath, stats);*/
          GetLastDirectory(startPath, name);
          listDirEntries = OnObject(owner, name, startPath, stats, true);
          if(listDirEntries)
@@ -45,7 +45,7 @@ public:
          {
             if(frame.listing.Find())
             {
-               FileStats stats = followLinks ? frame.listing.stats : frame.listing.lstats;
+               FileStats stats = /*followLinks ? */frame.listing.stats /*: frame.listing.lstats*/;
                listDirEntries = OnObject(owner, frame.listing.name, frame.listing.path, stats, !iterateStartPath && stack.count == 1);
                if(stats.attribs.isDirectory)
                {
@@ -101,18 +101,20 @@ public:
    bool iterateStartPath;
 
    virtual bool Iterate(char * startPath, bool followLinks);
-   virtual bool any_object::OnObject(/*any_object data, */char * name, char * path, FileStats stats, bool isRootObject);
-   virtual void any_object::OnEnteringDirectory(/*any_object data, */char * path);
-   virtual void any_object::OnLeavingDirectory(/*any_object data, */char * path);
+   virtual bool any_object::OnObject(/*any_object data, */const char * name, const char * path, FileStats stats, bool isRootObject);
+   virtual void any_object::OnEnteringDirectory(/*any_object data, */const char * path);
+   virtual void any_object::OnLeavingDirectory(/*any_object data, */const char * path);
 
 private:
 }
 
 // TODO: implement threaded iteration somehow....
+/*
 static class IteratorThread : Thread
 {
    void Temp()
    {
-      //listing = FileListing { dir, extensions = filter.extensions };  // there should be a sorted = true/false 
+      //listing = FileListing { dir, extensions = filter.extensions };  // there should be a sorted = true/false
    }
 }
+*/
index 690cd71..d198f1b 100644 (file)
@@ -12,7 +12,7 @@ struct SearchStackFrame
    int tag;
    char path[MAX_LOCATION];
    FileListing listing;
-   
+
    bool branched;
    //DataRow result;
    //DataRow browse;
@@ -47,7 +47,7 @@ public:
       terminate = false;
    }
 
-   virtual bool Window::NotifyUpdateSearchLocation(FileSystemSearch search, char * location);
+   virtual bool Window::NotifyUpdateSearchLocation(FileSystemSearch search, const char * location);
    virtual bool Window::NotifySearchSortResults(FileSystemSearch search);
    virtual bool Window::NotifySearchSortBrowser(FileSystemSearch search);
    virtual bool Window::NotifySearchTerminated(FileSystemSearch search);
@@ -61,7 +61,7 @@ public:
 
 
 
-   bool SearchFileContent(String path)
+   bool SearchFileContent(const String path)
    {
       bool match = false;
       File file = FileOpen(path, read);
@@ -96,8 +96,8 @@ public:
                      find = SearchString(buffer, start, contentSearch, optionContentMatchCase, optionContentMatchWord);
 
                      // todo add a maximum line length possibility as param
-                     for(bstart = start; 
-                           bstart < readCount && newLine && (!find || newLine < find); 
+                     for(bstart = start;
+                           bstart < readCount && newLine && (!find || newLine < find);
                               bstart += (newLine - &buffer[bstart]) / sizeof(char))
                      {
                         newLine = strstr(&buffer[bstart], "\n");
@@ -131,14 +131,14 @@ public:
                      find = SearchString(buffer, start, contentSearch, optionContentMatchCase, optionContentMatchWord);
                file.Seek(seekBack, current);
             }
-            match = (bool)find;
+            match = find != null;
          }
          delete file;
       }
       return match;
    }
-   
-   // I wonder if this is optimized at the c level to be compiled inline 
+
+   // I wonder if this is optimized at the c level to be compiled inline
    // and to use in-place in-stack memory for both the return value and the parameters
    // if not, c should be more optimized...
    // would the const have any impact on optimization?
@@ -155,24 +155,24 @@ public:
       // \\Nateus\data\ is not remote, etc...
       // How to?
       FileStats stats;
-      
+
       terminate = false;
       count = 0;
       matchCount = 0;
-      
+
       hasNameSearch = (strlen(nameSearch) != 0);
       hasSizeSearch = false;  // this is temporary
       hasContentSearch = (strlen(contentSearch) != 0);
 
       listLines = true;
       lines = OldList { };
-      
+
       //SearchDir(location);
 
       FileGetStats(location, stats);
 
       strcpy(stack[0].path, location);
-      stack[0].listing = FileListing { stack[0].path };  // there should be a sorted = true/false 
+      stack[0].listing = FileListing { stack[0].path };  // there should be a sorted = true/false
 
       //fsb.list.Clear();
                                                          // Binary Search sorting...
@@ -198,7 +198,7 @@ public:
          }
          guiApp.Unlock();
       }
-      
+
       for(frame = 0; frame >= 0 && !terminate; )
       {
          guiApp.Lock();
@@ -222,13 +222,13 @@ public:
          if(stack[frame].listing.Find())
          {
             count++;
-            
+
             //match = (strcmp(stack[frame].listing.name, nameSearch) == 0);
             //match = (stack[frame].listing.name[0] == nameSearch[0]);
             //match = (bool)strstr(stack[frame].listing.name, nameSearch);
-               
+
             if(hasNameSearch)
-               match = (bool)SearchString(stack[frame].listing.name, 0, nameSearch, optionNameMatchCase, optionNameMatchWord);
+               match = SearchString(stack[frame].listing.name, 0, nameSearch, optionNameMatchCase, optionNameMatchWord) != null;
             else
                match = true;