From: Rejean Loyer Date: Sun, 6 Oct 2013 02:43:23 +0000 (-0400) Subject: file sorting use case. hard coded paths. little bit of good stuff needs splitting... X-Git-Url: http://ecere.com/cgi-bin/gitweb.cgi?p=ede;a=commitdiff_plain;h=31c0bbb5b1181eb99fd55eba92dacb2ed14b3fb2 file sorting use case. hard coded paths. little bit of good stuff needs splitting into commit(s) for master branch. --- diff --git a/explorer/explorer.epj b/explorer/explorer.epj index 804866e..ead4c0f 100644 --- a/explorer/explorer.epj +++ b/explorer/explorer.epj @@ -25,7 +25,10 @@ "Name" : "Release", "Options" : { "Debug" : false, - "Optimization" : "Speed" + "Optimization" : "Speed", + "InstallCommands" : [ + "$(if $(WINDOWS_HOST),$(call cpq,$(TARGET),\"$(BINDIR)/\"),install $(INSTALL_FLAGS) $(TARGET) $(BINDIR)/$(MODULE)$(E))" + ] } }, { @@ -50,12 +53,12 @@ "Folder" : "extern", "Files" : [ { - "FileName" : "../../../sdk/extras/gui/controls/ToolBar.ec", + "FileName" : "../../../ecere-sdk/extras/gui/controls/ToolBar.ec", "Options" : { "ExcludeFromBuild" : true } }, - "../../../sdk/extras/gui/controls/SearchBox.ec" + "../../../ecere-sdk/extras/gui/controls/SearchBox.ec" ], "Configurations" : [ { diff --git a/explorer/src/Explorer.ec b/explorer/src/Explorer.ec index 134b675..58c86a2 100644 --- a/explorer/src/Explorer.ec +++ b/explorer/src/Explorer.ec @@ -102,9 +102,39 @@ class Explorer : GuiApplication goPath = openArgsStartAt == -1 ? "" : argv[c]; if(goPath) { - ExplorerWindow explorerWnd { }; - explorerWnd.Create(); - explorerWnd.location = goPath;//explorerWnd.GoTo(goPath, false, false); + if(false)//(c == 1) + { + FileStats stats; + //Map linksPaths { }; + //Map> devsInodesDone { }; + //FileSystemCache cache; + // dw = { visible = false }; + ///*cache = */FileSystemCache::Cache("/", true, dw); + + // FileSystemCache::Cache("/s1", true, false, true, dw); + // FileSystemCache::Cache("/s2/0z", true, false, true, dw); + //dw.cache.Special("/s2/0z/0sort", dw); + //dw.cache.Special("/s2/library", dw); + //dw.cache.Special("/s2/mirror", dw); + // dw.cache.SpecialPrint(); + //devsInodesDone.Free(); + //delete devsInodesDone; + + /*{ + ExplorerWindow explorerWnd { testCache = dw.cache }; + explorerWnd.Create(); + explorerWnd.location = goPath;//explorerWnd.GoTo(goPath, false, false); + }*/ + // PrintLn("# of objects: ", dw.cache.objects.count); + // PrintLn("# of non single file sizes: ", dw.cache.nonSingleSizes.count); + // delete dw; + } + else + { + ExplorerWindow explorerWnd { }; + explorerWnd.Create(); + explorerWnd.location = goPath;//explorerWnd.GoTo(goPath, false, false); + } } } } diff --git a/libede/EDE.epj b/libede/EDE.epj index 6509ee5..2285586 100644 --- a/libede/EDE.epj +++ b/libede/EDE.epj @@ -1,6 +1,7 @@ { "Version" : 0.2, "ModuleName" : "EDE", + "ModuleVersion" : "0.44", "Options" : { "Warnings" : "All", "DefaultNameSpace" : "ede", @@ -25,7 +26,12 @@ "Name" : "Release", "Options" : { "Debug" : false, - "Optimization" : "Speed" + "Optimization" : "Speed", + "InstallCommands" : [ + "$(call cpq,$(TARGET),\"$(DESTLIBDIR)/\")", + "$(if $(WINDOWS_HOST),,ln -sf $(LP)$(MODULE)$(SOV) $(DESTLIBDIR)/$(LP)$(MODULE)$(SO).0)", + "$(if $(WINDOWS_HOST),,ln -sf $(LP)$(MODULE)$(SOV) $(DESTLIBDIR)/$(LP)$(MODULE)$(SO))" + ] } }, { diff --git a/libede/src/FileSystemCache.ec b/libede/src/FileSystemCache.ec index 03920bd..34ec228 100644 --- a/libede/src/FileSystemCache.ec +++ b/libede/src/FileSystemCache.ec @@ -94,6 +94,8 @@ private: class FileSystemCacheBits { bool indexInodes:1; + bool indexByName:1; + bool indexBySize:1; } public class DummyFileSystemCacheWindow : Window @@ -110,9 +112,16 @@ public: Array normalParentStack; Map deviceCaches { }; + Map> nameIndex { }; + Map nonSingleNames { }; + Map> sizeIndex { }; + Map nonSingleSizes { }; + property bool indexInodes { set { bits.indexInodes = value; } get { return bits.indexInodes; } }; + property bool indexByName { set { bits.indexByName = value; } get { return bits.indexByName; } }; + property bool indexBySize { set { bits.indexBySize = value; } get { return bits.indexBySize; } }; - void/*FileSystemCache*/ ::Cache(char * path, bool indexInodes, DummyFileSystemCacheWindow dummyWindow) + void/*FileSystemCache*/ ::Cache(char * path, bool indexInodes, bool indexByName, bool indexBySize, DummyFileSystemCacheWindow dummyWindow) { FileSystemCache cache = dummyWindow.cache; // TOIMP: for now we will assume the cache includes files from a single domain (partition/share) @@ -122,6 +131,8 @@ public: { cache = dummyWindow.cache;// = { }; cache.indexInodes = indexInodes; + cache.indexByName = indexByName; + cache.indexBySize = indexBySize; cache.normalParentStack = { }; //cache.domainParentStack = { }; if(pathAttribs.isDirectory) @@ -136,8 +147,8 @@ public: { bool result = true; FileSystemCache cache = this.cache; - uint dev = stats.dev; - uint inode = stats.inode; + uint dev = 0;//stats.dev; + uint inode = 0;//stats.inode; char * p; FSCacheObject parent = isRootObject ? null : cache.normalParentStack.lastIterator.data; FSCacheObject o { parent, name = CopyString(isRootObject ? path : name), stats = stats }; @@ -165,6 +176,7 @@ public: #if _DEBUG if(cache.objects.count % 1000 == 0) PrintLn(path, " ----- ", cache.objects.count / 1000, " --------- ", dev); +#if 0 FileGetStatsLink(path, s); if(s.inode != inode) { @@ -189,19 +201,31 @@ public: } delete p; #endif - if(dev && inode && cache.bits.indexInodes) +#endif + if(!stats.attribs.isDirectory) { - FileSystemDeviceCache devCache = cache.deviceCaches[dev]; - if(!devCache) - cache.deviceCaches[dev] = devCache = { }; + if(dev && inode && cache.bits.indexInodes) { - Array inodes = devCache.inodes[inode]; - if(!inodes) - devCache.inodes[inode] = inodes = { }; - else if(inodes.count == 1) - devCache.nonSingleLinks[inode] = true; - inodes.Add(o); + FileSystemDeviceCache devCache = cache.deviceCaches[dev]; + if(!devCache) + cache.deviceCaches[dev] = devCache = { }; + { + Array files = devCache.inodes[inode]; + if(!files) + { + devCache.inodes[inode] = files = { }; + if(cache.bits.indexBySize) + CacheAddFileToIndexBySize(cache, o, stats.size); + } + else if(files.count == 1) + devCache.nonSingleLinks[inode] = true; + files.Add(o); + } } + else if(cache.bits.indexBySize) + CacheAddFileToIndexBySize(cache, o, stats.size); + if(cache.bits.indexByName) + CacheAddFileToIndexByName(cache, o, name); } return result; } @@ -307,6 +331,7 @@ public: Map> devsInodesDone { }; Map linksPaths { }; +#if 0 void Special(char * path/*, Map linksPaths*//*Map> devsInodesDone*/, DummyFileSystemCacheWindow dummyWindow) { FileSystemCacheIterator fsci { owner = dummyWindow, cache = this, iterateStartPath = true; @@ -364,10 +389,41 @@ public: MapNode mn; PrintLn(" -------------------------------------------- Special -------------------------------------------- "); PrintLn(" ------------------------------------------------------------------------------------------------- "); - for(mn = linksPaths.root.minimum; mn; mn = mn.next) + if(linksPaths.count) + { + for(mn = linksPaths.root.minimum; mn; mn = mn.next) + { + PrintLn(mn.key); + } + } + else + PrintLn(" no hard linked files"); + PrintLn(" ------------------------------------------------------------------------------------------------- "); + } +#endif + void Special(char * path/*, Map linksPaths*//*Map> devsInodesDone*/, DummyFileSystemCacheWindow dummyWindow) + { + } + void SpecialPrint() + { + MapNode mn; + PrintLn(" -------------------------------------------- Special -------------------------------------------- "); + PrintLn(" ------------------------------------------------------------------------------------------------- "); + if(nonSingleSizes.count) { - PrintLn(mn.key); + for(mn = nonSingleSizes.root.minimum; mn; mn = mn.next) + { + Array files = sizeIndex[mn.key]; + PrintLn(" size: ", mn.value, "# of files: ", files.count); + for(o : files) + { + char * p = o.GetPath(); + PrintLn(p); + delete p; + } + } } + PrintLn(" ------------------------------------------------------------------------------------------------- "); } private: @@ -378,8 +434,30 @@ private: objects.Free(); delete objects; } + +} + +static inline void CacheAddFileToIndexBySize(FileSystemCache cache, FSCacheObject o, FileSize size) +{ + Array files = cache.sizeIndex[size]; + if(!files) + cache.sizeIndex[size] = files = { }; + else if(files.count == 1) + cache.nonSingleSizes[size] = true; + files.Add(o); } +static inline void CacheAddFileToIndexByName(FileSystemCache cache, FSCacheObject o, char * name) +{ + Array files = cache.nameIndex[name]; + if(!files) + cache.nameIndex[name] = files = { }; + else if(files.count == 1) + cache.nonSingleNames[name] = true; + files.Add(o); +} + + public class FileSystemDeviceCache : struct { public: diff --git a/libede/src/FileSystemIterator.ec b/libede/src/FileSystemIterator.ec index 6c2cab3..0a5fa34 100644 --- a/libede/src/FileSystemIterator.ec +++ b/libede/src/FileSystemIterator.ec @@ -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 = frame.listing.stats; //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) {