]> git.tdb.fi Git - builder.git/commitdiff
Ensure that the directory exists before trying to write the cache
authorMikko Rasa <tdb@tdb.fi>
Sat, 21 Jul 2012 13:46:29 +0000 (16:46 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 21 Jul 2012 13:46:29 +0000 (16:46 +0300)
source/cache.cpp

index 087428fc3cf54cf8341deae68dcb4224b6f3613b..d4a4ebc3857f25321fbb27d756d77aa02446d98b 100644 (file)
@@ -1,5 +1,7 @@
 #include <msp/core/maputils.h>
+#include <msp/fs/dir.h>
 #include <msp/fs/stat.h>
+#include <msp/fs/utils.h>
 #include <msp/io/file.h>
 #include <msp/io/print.h>
 #include <msp/strings/utils.h>
@@ -133,6 +135,9 @@ void Cache::save() const
        if(data.empty() || !changed)
                return;
 
+       FS::Path dir = FS::dirname(filename);
+       if(!FS::exists(dir))
+               FS::mkpath(dir, 0755);
        package.get_builder().get_logger().log("files", format("Writing %s", filename));
        IO::BufferedFile out(filename.str(), IO::M_WRITE);