From 6936b33b44b0f2401487140229b39fbc41fae6b3 Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Mon, 12 Apr 2004 15:55:36 +0000 Subject: [PATCH] fix Entry::read_tree() and get_next_path_component() svn path=/branches/lean-explorer/; revision=9104 --- .../subsys/system/explorer/shell/entries.cpp | 27 ++++--------------- .../subsys/system/explorer/shell/entries.h | 5 +--- .../subsys/system/explorer/shell/shellfs.cpp | 2 +- .../subsys/system/explorer/shell/shellfs.h | 2 +- .../subsys/system/explorer/shell/winfs.cpp | 17 ++++++++++++ reactos/subsys/system/explorer/shell/winfs.h | 1 + 6 files changed, 26 insertions(+), 28 deletions(-) diff --git a/reactos/subsys/system/explorer/shell/entries.cpp b/reactos/subsys/system/explorer/shell/entries.cpp index 22fcdbe8533..90aacf91ab0 100644 --- a/reactos/subsys/system/explorer/shell/entries.cpp +++ b/reactos/subsys/system/explorer/shell/entries.cpp @@ -119,17 +119,17 @@ Entry* Entry::read_tree(const void* path, SORT_ORDER sortOrder) HCURSOR old_cursor = SetCursor(LoadCursor(0, IDC_WAIT)); Entry* entry = this; - Entry* next_entry = entry; - - for(const void*p=path; p&&next_entry; p=entry->get_next_path_component(p)) { - entry = next_entry; + for(const void*p=path; p && entry; ) { entry->read_directory(sortOrder); if (entry->_down) entry->_expanded = true; - next_entry = entry->find_entry(p); + Entry* next_entry = entry->find_entry(p); + p = entry->get_next_path_component(p); + + entry = next_entry; } SetCursor(old_cursor); @@ -473,20 +473,3 @@ void Entry::free_subentries() } while(next); } } - - -const void* Directory::get_next_path_component(const void* p) -{ - LPCTSTR s = (LPCTSTR) p; - - while(*s && *s!=TEXT('\\') && *s!=TEXT('/')) - ++s; - - while(*s==TEXT('\\') || *s==TEXT('/')) - ++s; - - if (!*s) - return NULL; - - return s; -} diff --git a/reactos/subsys/system/explorer/shell/entries.h b/reactos/subsys/system/explorer/shell/entries.h index 3aa7a66d80e..3e83ad5fa10 100644 --- a/reactos/subsys/system/explorer/shell/entries.h +++ b/reactos/subsys/system/explorer/shell/entries.h @@ -99,7 +99,7 @@ public: void extract_icon(); virtual void read_directory(int scan_flags=SCAN_ALL) {} - virtual const void* get_next_path_component(const void*) {return NULL;} + virtual const void* get_next_path_component(const void*) const {return NULL;} virtual Entry* find_entry(const void*) {return NULL;} virtual bool get_path(PTSTR path) const = 0; virtual ShellPath create_absolute_pidl() const {return (LPCITEMIDLIST)NULL;} @@ -114,9 +114,6 @@ protected: Directory() : _path(NULL) {} virtual ~Directory() {} - // default implementation like that of Windows file systems - virtual const void* get_next_path_component(const void*); - void* _path; }; diff --git a/reactos/subsys/system/explorer/shell/shellfs.cpp b/reactos/subsys/system/explorer/shell/shellfs.cpp index 7d960f1f1aa..e4f1ab90240 100644 --- a/reactos/subsys/system/explorer/shell/shellfs.cpp +++ b/reactos/subsys/system/explorer/shell/shellfs.cpp @@ -428,7 +428,7 @@ void ShellDirectory::read_directory(int scan_flags) _scanned = true; } -const void* ShellDirectory::get_next_path_component(const void* p) +const void* ShellDirectory::get_next_path_component(const void* p) const { LPITEMIDLIST pidl = (LPITEMIDLIST)p; diff --git a/reactos/subsys/system/explorer/shell/shellfs.h b/reactos/subsys/system/explorer/shell/shellfs.h index e45127b9821..e436b6c53a7 100644 --- a/reactos/subsys/system/explorer/shell/shellfs.h +++ b/reactos/subsys/system/explorer/shell/shellfs.h @@ -99,7 +99,7 @@ struct ShellDirectory : public ShellEntry, public Directory } virtual void read_directory(int scan_flags=SCAN_ALL); - virtual const void* get_next_path_component(const void*); + virtual const void* get_next_path_component(const void*) const; virtual Entry* find_entry(const void* p); virtual bool get_path(PTSTR path) const; diff --git a/reactos/subsys/system/explorer/shell/winfs.cpp b/reactos/subsys/system/explorer/shell/winfs.cpp index 22aeafdf900..51808e7b768 100644 --- a/reactos/subsys/system/explorer/shell/winfs.cpp +++ b/reactos/subsys/system/explorer/shell/winfs.cpp @@ -100,6 +100,23 @@ void WinDirectory::read_directory(int scan_flags) } +const void* WinDirectory::get_next_path_component(const void* p) const +{ + LPCTSTR s = (LPCTSTR) p; + + while(*s && *s!=TEXT('\\') && *s!=TEXT('/')) + ++s; + + while(*s==TEXT('\\') || *s==TEXT('/')) + ++s; + + if (!*s) + return NULL; + + return s; +} + + Entry* WinDirectory::find_entry(const void* p) { LPCTSTR name = (LPCTSTR)p; diff --git a/reactos/subsys/system/explorer/shell/winfs.h b/reactos/subsys/system/explorer/shell/winfs.h index efd94239e88..5c658145598 100644 --- a/reactos/subsys/system/explorer/shell/winfs.h +++ b/reactos/subsys/system/explorer/shell/winfs.h @@ -61,5 +61,6 @@ struct WinDirectory : public WinEntry, public Directory } virtual void read_directory(int scan_flags=SCAN_ALL); + virtual const void* get_next_path_component(const void* p) const; virtual Entry* find_entry(const void*); };