[Bf-blender-cvs] [527e8ce] alembic_pointcache: Make sure the output directory for cache files exists before trying to create the Alembic OArchive, otherwise HDF5 throws an exception.

Lukas Tönne noreply at git.blender.org
Thu Oct 16 16:53:04 CEST 2014


Commit: 527e8ce74db4fd97568d0d55202829815eb2d537
Author: Lukas Tönne
Date:   Mon Nov 25 15:39:02 2013 +0100
Branches: alembic_pointcache
https://developer.blender.org/rB527e8ce74db4fd97568d0d55202829815eb2d537

Make sure the output directory for cache files exists before trying
to create the Alembic OArchive, otherwise HDF5 throws an exception.

===================================================================

M	source/blender/pointcache/intern/writer.cpp
M	source/blender/pointcache/util/util_path.cpp

===================================================================

diff --git a/source/blender/pointcache/intern/writer.cpp b/source/blender/pointcache/intern/writer.cpp
index cfe6bb0..4a3eff3 100644
--- a/source/blender/pointcache/intern/writer.cpp
+++ b/source/blender/pointcache/intern/writer.cpp
@@ -20,12 +20,26 @@
 
 #include "writer.h"
 
+extern "C" {
+#include "BLI_fileops.h"
+#include "BLI_path_util.h"
+}
+
 namespace PTC {
 
 using namespace Abc;
 
+/* make sure the file's directory exists */
+static void ensure_directory(const char *filename)
+{
+	char dir[FILE_MAXDIR];
+	BLI_split_dir_part(filename, dir, sizeof(dir));
+	BLI_dir_create_recursive(dir);
+}
+
 Writer::Writer(const std::string &filename)
 {
+	ensure_directory(filename.c_str());
 	m_archive = OArchive(AbcCoreHDF5::WriteArchive(), filename, ErrorHandler::kThrowPolicy);
 }
 
diff --git a/source/blender/pointcache/util/util_path.cpp b/source/blender/pointcache/util/util_path.cpp
index 6e29468..7fec1ab 100644
--- a/source/blender/pointcache/util/util_path.cpp
+++ b/source/blender/pointcache/util/util_path.cpp
@@ -68,8 +68,8 @@ static int ptc_path(char *filename, const char *path, ID *id, bool is_external,
 static int ptc_filename(char *filename, const char *name, int index, const char *path, ID *id,
                         bool do_path, bool do_ext, bool is_external, bool ignore_libpath)
 {
-	char *newname = filename;
-	int len=0;
+	char *newname;
+	int len = 0;
 	filename[0] = '\0';
 	newname = filename;




More information about the Bf-blender-cvs mailing list