From ddaf3f172f740112d644a36e5371996147b4b372 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 6 Aug 2009 21:16:03 +0000 Subject: [PATCH] add remove_subfile(string) --- panda/src/express/multifile.I | 25 +++++++++++++++++++++++++ panda/src/express/multifile.h | 1 + 2 files changed, 26 insertions(+) diff --git a/panda/src/express/multifile.I b/panda/src/express/multifile.I index 287a7e0e2f..51ea640f66 100644 --- a/panda/src/express/multifile.I +++ b/panda/src/express/multifile.I @@ -328,6 +328,31 @@ get_encryption_iteration_count() const { return _encryption_iteration_count; } +//////////////////////////////////////////////////////////////////// +// Function: Multifile::remove_subfile +// Access: Published +// Description: Removes the named subfile from the Multifile, if it +// exists; returns true if successfully removed, or +// false if it did not exist in the first place. The +// file will not actually be removed from the disk until +// the next call to flush(). +// +// Note that this does not actually remove the data from +// the indicated subfile; it simply removes it from the +// index. The Multifile will not be reduced in size +// after this operation, until the next call to +// repack(). +//////////////////////////////////////////////////////////////////// +INLINE bool Multifile:: +remove_subfile(const string &subfile_name) { + int index = find_subfile(subfile_name); + if (index >= 0) { + remove_subfile(index); + return true; + } + return false; +} + //////////////////////////////////////////////////////////////////// // Function: Multifile::read_subfile // Access: Published diff --git a/panda/src/express/multifile.h b/panda/src/express/multifile.h index 89824a9d55..550107c64c 100644 --- a/panda/src/express/multifile.h +++ b/panda/src/express/multifile.h @@ -90,6 +90,7 @@ PUBLISHED: bool scan_directory(vector_string &contents, const string &subfile_name) const; void remove_subfile(int index); + INLINE bool remove_subfile(const string &subfile_name); const string &get_subfile_name(int index) const; MAKE_SEQ(get_subfile_names, get_num_subfiles, get_subfile_name); size_t get_subfile_length(int index) const;