Browse Source

add remove_subfile(string)

David Rose 16 years ago
parent
commit
ddaf3f172f
2 changed files with 26 additions and 0 deletions
  1. 25 0
      panda/src/express/multifile.I
  2. 1 0
      panda/src/express/multifile.h

+ 25 - 0
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

+ 1 - 0
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;