Add Asset::set_file_preserving_hash().
authorCarl Hetherington <cth@carlh.net>
Tue, 20 Jun 2023 20:06:02 +0000 (22:06 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 26 Jun 2023 22:06:50 +0000 (00:06 +0200)
src/asset.cc
src/asset.h

index cd56c3ea4b2afe2a6cd69a557cad3a2442bc44dd..b69e68e8589d53c7e3e94cd09bee8525e5fdb5d8 100644 (file)
@@ -162,6 +162,13 @@ Asset::set_file (path file) const
 }
 
 
+void
+Asset::set_file_preserving_hash(path file) const
+{
+       _file = absolute(file);
+}
+
+
 void
 Asset::rename_file(path file)
 {
index 923720ff144673918ff92e6173ff2bbdda80e8a6..c5d50010a5ce927de5db767c62b693d92803c760 100644 (file)
@@ -109,6 +109,15 @@ public:
         */
        void set_file (boost::filesystem::path file) const;
 
+       /** Set the file that holds this asset on disk.  Calling this function
+        *  preserves the object's store of its hash, so if the object already
+        *  has a hash it is up to the caller to ensure that the new file has
+        *  the same hash.
+        *
+        *  @param file New file's path.
+        */
+       void set_file_preserving_hash(boost::filesystem::path file) const;
+
        /** Set the file that holds this asset on disk.  The new file must
         *  be exactly the same as the old one, as this function assumes
         *  that the object's hash does not change.