Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/packedFile.c')
-rw-r--r--source/blender/blenkernel/intern/packedFile.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index d69527e8626..34e86b29540 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -37,6 +37,7 @@
#include "DNA_ID.h"
#include "DNA_packedFile_types.h"
#include "DNA_sound_types.h"
+#include "DNA_volume_types.h"
#include "DNA_vfont_types.h"
#include "BLI_blenlib.h"
@@ -48,6 +49,7 @@
#include "BKE_packedFile.h"
#include "BKE_report.h"
#include "BKE_sound.h"
+#include "BKE_volume.h"
int BKE_packedfile_seek(PackedFile *pf, int offset, int whence)
{
@@ -114,6 +116,7 @@ int BKE_packedfile_count_all(Main *bmain)
Image *ima;
VFont *vf;
bSound *sound;
+ Volume *volume;
int count = 0;
/* let's check if there are packed files... */
@@ -135,6 +138,12 @@ int BKE_packedfile_count_all(Main *bmain)
}
}
+ for (volume = bmain->volumes.first; volume; volume = volume->id.next) {
+ if (volume->packedfile) {
+ count++;
+ }
+ }
+
return count;
}
@@ -234,6 +243,7 @@ void BKE_packedfile_pack_all(Main *bmain, ReportList *reports, bool verbose)
Image *ima;
VFont *vfont;
bSound *sound;
+ Volume *volume;
int tot = 0;
for (ima = bmain->images.first; ima; ima = ima->id.next) {
@@ -266,6 +276,14 @@ void BKE_packedfile_pack_all(Main *bmain, ReportList *reports, bool verbose)
}
}
+ for (volume = bmain->volumes.first; volume; volume = volume->id.next) {
+ if (volume->packedfile == NULL && !ID_IS_LINKED(volume)) {
+ volume->packedfile = BKE_packedfile_new(
+ reports, volume->filepath, BKE_main_blendfile_path(bmain));
+ tot++;
+ }
+ }
+
if (tot > 0) {
BKE_reportf(reports, RPT_INFO, "Packed %d file(s)", tot);
}
@@ -524,6 +542,9 @@ static void unpack_generate_paths(const char *name,
case ID_IM:
BLI_snprintf(r_relpath, relpathlen, "//textures/%s", tempname);
break;
+ case ID_VO:
+ BLI_snprintf(r_relpath, relpathlen, "//volumes/%s", tempname);
+ break;
default:
break;
}
@@ -643,6 +664,36 @@ int BKE_packedfile_unpack_image(Main *bmain,
return (ret_value);
}
+int BKE_packedfile_unpack_volume(Main *bmain,
+ ReportList *reports,
+ Volume *volume,
+ enum ePF_FileStatus how)
+{
+ char localname[FILE_MAX], absname[FILE_MAX];
+ char *newfilepath;
+ int ret_value = RET_ERROR;
+
+ if (volume != NULL) {
+ unpack_generate_paths(
+ volume->filepath, (ID *)volume, absname, localname, sizeof(absname), sizeof(localname));
+ newfilepath = BKE_packedfile_unpack_to_file(
+ reports, BKE_main_blendfile_path(bmain), absname, localname, volume->packedfile, how);
+ if (newfilepath != NULL) {
+ BLI_strncpy(volume->filepath, newfilepath, sizeof(volume->filepath));
+ MEM_freeN(newfilepath);
+
+ BKE_packedfile_free(volume->packedfile);
+ volume->packedfile = NULL;
+
+ BKE_volume_unload(volume);
+
+ ret_value = RET_OK;
+ }
+ }
+
+ return (ret_value);
+}
+
int BKE_packedfile_unpack_all_libraries(Main *bmain, ReportList *reports)
{
Library *lib;
@@ -702,6 +753,7 @@ void BKE_packedfile_unpack_all(Main *bmain, ReportList *reports, enum ePF_FileSt
Image *ima;
VFont *vf;
bSound *sound;
+ Volume *volume;
for (ima = bmain->images.first; ima; ima = ima->id.next) {
if (BKE_image_has_packedfile(ima)) {
@@ -720,6 +772,12 @@ void BKE_packedfile_unpack_all(Main *bmain, ReportList *reports, enum ePF_FileSt
BKE_packedfile_unpack_sound(bmain, reports, sound, how);
}
}
+
+ for (volume = bmain->volumes.first; volume; volume = volume->id.next) {
+ if (volume->packedfile) {
+ BKE_packedfile_unpack_volume(bmain, reports, volume, how);
+ }
+ }
}
/* ID should be not NULL, return 1 if there's a packed file */
@@ -738,6 +796,10 @@ bool BKE_packedfile_id_check(ID *id)
bSound *snd = (bSound *)id;
return snd->packedfile != NULL;
}
+ case ID_VO: {
+ Volume *volume = (Volume *)id;
+ return volume->packedfile != NULL;
+ }
case ID_LI: {
Library *li = (Library *)id;
return li->packedfile != NULL;
@@ -773,6 +835,13 @@ void BKE_packedfile_id_unpack(Main *bmain, ID *id, ReportList *reports, enum ePF
}
break;
}
+ case ID_VO: {
+ Volume *volume = (Volume *)id;
+ if (volume->packedfile) {
+ BKE_packedfile_unpack_volume(bmain, reports, volume, how);
+ }
+ break;
+ }
case ID_LI: {
Library *li = (Library *)id;
BKE_reportf(reports, RPT_ERROR, "Cannot unpack individual Library file, '%s'", li->name);