|
@@ -194,8 +194,14 @@ class BlobIOSystem : public IOSystem {
|
|
|
friend class BlobIOStream;
|
|
|
typedef std::pair<std::string, aiExportDataBlob *> BlobEntry;
|
|
|
|
|
|
+
|
|
|
public:
|
|
|
- BlobIOSystem() {
|
|
|
+ BlobIOSystem() :
|
|
|
+ baseName{AI_BLOBIO_MAGIC} {
|
|
|
+ }
|
|
|
+
|
|
|
+ BlobIOSystem(const std::string &baseName) :
|
|
|
+ baseName(baseName) {
|
|
|
}
|
|
|
|
|
|
virtual ~BlobIOSystem() {
|
|
@@ -207,27 +213,32 @@ public:
|
|
|
public:
|
|
|
// -------------------------------------------------------------------
|
|
|
const char *GetMagicFileName() const {
|
|
|
- return AI_BLOBIO_MAGIC;
|
|
|
+ return baseName.c_str();
|
|
|
}
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
aiExportDataBlob *GetBlobChain() {
|
|
|
+ const auto magicName = std::string(this->GetMagicFileName());
|
|
|
+ const bool hasBaseName = baseName != AI_BLOBIO_MAGIC;
|
|
|
+
|
|
|
// one must be the master
|
|
|
aiExportDataBlob *master = nullptr, *cur;
|
|
|
+
|
|
|
for (const BlobEntry &blobby : blobs) {
|
|
|
- if (blobby.first == AI_BLOBIO_MAGIC) {
|
|
|
+ if (blobby.first == magicName) {
|
|
|
master = blobby.second;
|
|
|
+ master->name.Set(hasBaseName ? blobby.first : "");
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if (!master) {
|
|
|
ASSIMP_LOG_ERROR("BlobIOSystem: no data written or master file was not closed properly.");
|
|
|
return nullptr;
|
|
|
}
|
|
|
|
|
|
- master->name.Set("");
|
|
|
-
|
|
|
cur = master;
|
|
|
+
|
|
|
for (const BlobEntry &blobby : blobs) {
|
|
|
if (blobby.second == master) {
|
|
|
continue;
|
|
@@ -236,9 +247,13 @@ public:
|
|
|
cur->next = blobby.second;
|
|
|
cur = cur->next;
|
|
|
|
|
|
- // extract the file extension from the file written
|
|
|
- const std::string::size_type s = blobby.first.find_first_of('.');
|
|
|
- cur->name.Set(s == std::string::npos ? blobby.first : blobby.first.substr(s + 1));
|
|
|
+ if (hasBaseName) {
|
|
|
+ cur->name.Set(blobby.first);
|
|
|
+ } else {
|
|
|
+ // extract the file extension from the file written
|
|
|
+ const std::string::size_type s = blobby.first.find_first_of('.');
|
|
|
+ cur->name.Set(s == std::string::npos ? blobby.first : blobby.first.substr(s + 1));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// give up blob ownership
|
|
@@ -283,6 +298,7 @@ private:
|
|
|
}
|
|
|
|
|
|
private:
|
|
|
+ std::string baseName;
|
|
|
std::set<std::string> created;
|
|
|
std::vector<BlobEntry> blobs;
|
|
|
};
|