Skip to content

Commit

Permalink
Clear file list after use
Browse files Browse the repository at this point in the history
The remote implementation of the RDirObject class was not clearing out
its list when close() was called, resulting in duplicate entries in
Brunel's FileTree.
  • Loading branch information
Colin Ward committed Jun 9, 2024
1 parent d036e66 commit 7c8c4c4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 1 addition & 3 deletions Dir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,9 +955,7 @@ TInt RDir::open(const char *a_pccPattern)

void RDir::close()
{
/* Free the contents of the TEntry array in case it the RDir class is reused */

m_entries.Purge();
RDirObject::close();

#ifdef __amigaos__

Expand Down
7 changes: 6 additions & 1 deletion Dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,12 @@ class RDirObject

virtual TInt open(const char *a_pattern) = 0;

virtual void close() = 0;
virtual void close()
{
/* Free the contents of the TEntry array in case the RDir class is reused */

m_entries.Purge();
}

virtual TInt read(TEntryArray *&a_entries, enum TDirSortOrder a_sortOrder = EDirSortNone) = 0;
};
Expand Down
2 changes: 0 additions & 2 deletions RemoteDir.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class RRemoteDir : public RDirObject

int open(const char *a_pattern);

void close() { }

int read(TEntryArray *&a_entries, enum TDirSortOrder a_sortOrder = EDirSortNone);

void setFactory(RRemoteFactory *a_remoteFactory) { m_remoteFactory = a_remoteFactory; }
Expand Down
2 changes: 1 addition & 1 deletion RemoteFileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ int RRemoteFileUtils::deleteFile(const char *a_fileName)

int RRemoteFileUtils::getFileInfo(const char *a_fileName, TEntry *a_entry)
{
ASSERTM((a_entry != nullptr), "RRemoteFileUtils::getFileInfo() => Pointer to filename passed in must not be NULL");
ASSERTM((a_fileName!= nullptr), "RRemoteFileUtils::getFileInfo() => Pointer to filename passed in must not be NULL");
ASSERTM((a_entry != nullptr), "RRemoteFileUtils::getFileInfo() => TEntry structure passed in must not be NULL");

RSocket socket;
Expand Down

0 comments on commit 7c8c4c4

Please sign in to comment.