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.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index 0041cd33c14..2c8975e9cb4 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -182,7 +182,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
// convert relative filenames to absolute filenames
- BLI_strncpy(name, filename, sizeof(name));
+ strcpy(name, filename);
BLI_path_abs(name, basepath);
// open the file
@@ -240,7 +240,7 @@ void packAll(Main *bmain, ReportList *reports)
}
-#if 0
+/*
// attempt to create a function that generates an unique filename
// this will work when all funtions in fileops.c understand relative filenames...
@@ -249,7 +249,6 @@ static char *find_new_name(char *name)
{
char tempname[FILE_MAXDIR + FILE_MAXFILE];
char *newname;
- size_t len;
if (fop_exists(name)) {
for (number = 1; number <= 999; number++) {
@@ -259,12 +258,14 @@ static char *find_new_name(char *name)
}
}
}
- len= strlen(tempname) + 1;
- newname = MEM_mallocN(len, "find_new_name");
- memcpy(newname, tempname, len * sizeof(char));
- return newname;
+
+ newname = mallocN(strlen(tempname) + 1, "find_new_name");
+ strcpy(newname, tempname);
+
+ return(newname);
}
-#endif
+
+*/
int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, int guimode)
{
@@ -276,12 +277,12 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
if (guimode) {} //XXX waitcursor(1);
- BLI_strncpy(name, filename, sizeof(name));
+ strcpy(name, filename);
BLI_path_abs(name, G.main->name);
if (BLI_exists(name)) {
for (number = 1; number <= 999; number++) {
- BLI_snprintf(tempname, sizeof(tempname), "%s.%03d_", name, number);
+ sprintf(tempname, "%s.%03d_", name, number);
if (! BLI_exists(tempname)) {
if (BLI_copy_fileops(name, tempname) == RET_OK) {
remove_tmp = TRUE;
@@ -341,7 +342,7 @@ int checkPackedFile(const char *filename, PackedFile *pf)
char buf[4096];
char name[FILE_MAXDIR + FILE_MAXFILE];
- BLI_strncpy(name, filename, sizeof(name));
+ strcpy(name, filename);
BLI_path_abs(name, G.main->name);
if (stat(name, &st)) {
@@ -391,10 +392,9 @@ there was an error or when the user desides to cancel the operation.
*/
-char *unpackFile(ReportList *reports, const char *abs_name, const char *local_name, PackedFile *pf, int how)
+char *unpackFile(ReportList *reports, char *abs_name, char *local_name, PackedFile *pf, int how)
{
- char *newname = NULL;
- const char *temp = NULL;
+ char *newname = NULL, *temp = NULL;
// char newabs[FILE_MAXDIR + FILE_MAXFILE];
// char newlocal[FILE_MAXDIR + FILE_MAXFILE];
@@ -437,11 +437,12 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
}
if (temp) {
- newname= BLI_strdup(temp);
+ newname = MEM_mallocN(strlen(temp) + 1, "unpack_file newname");
+ strcpy(newname, temp);
}
}
- return newname;
+ return (newname);
}
@@ -452,17 +453,17 @@ int unpackVFont(ReportList *reports, VFont *vfont, int how)
int ret_value = RET_ERROR;
if (vfont != NULL) {
- BLI_strncpy(localname, vfont->name, sizeof(localname));
+ strcpy(localname, vfont->name);
BLI_splitdirstring(localname, fi);
- BLI_snprintf(localname, sizeof(localname), "//fonts/%s", fi);
+ sprintf(localname, "//fonts/%s", fi);
newname = unpackFile(reports, vfont->name, localname, vfont->packedfile, how);
if (newname != NULL) {
ret_value = RET_OK;
freePackedFile(vfont->packedfile);
vfont->packedfile = NULL;
- BLI_strncpy(vfont->name, newname, sizeof(vfont->name));
+ strcpy(vfont->name, newname);
MEM_freeN(newname);
}
}
@@ -477,13 +478,13 @@ int unpackSound(Main *bmain, ReportList *reports, bSound *sound, int how)
int ret_value = RET_ERROR;
if (sound != NULL) {
- BLI_strncpy(localname, sound->name, sizeof(localname));
+ strcpy(localname, sound->name);
BLI_splitdirstring(localname, fi);
- BLI_snprintf(localname, sizeof(localname), "//sounds/%s", fi);
+ sprintf(localname, "//sounds/%s", fi);
newname = unpackFile(reports, sound->name, localname, sound->packedfile, how);
if (newname != NULL) {
- BLI_strncpy(sound->name, newname, sizeof(sound->name));
+ strcpy(sound->name, newname);
MEM_freeN(newname);
freePackedFile(sound->packedfile);
@@ -505,16 +506,16 @@ int unpackImage(ReportList *reports, Image *ima, int how)
int ret_value = RET_ERROR;
if (ima != NULL) {
- BLI_strncpy(localname, ima->name, sizeof(localname));
+ strcpy(localname, ima->name);
BLI_splitdirstring(localname, fi);
- BLI_snprintf(localname, sizeof(localname), "//textures/%s", fi);
-
+ sprintf(localname, "//textures/%s", fi);
+
newname = unpackFile(reports, ima->name, localname, ima->packedfile, how);
if (newname != NULL) {
ret_value = RET_OK;
freePackedFile(ima->packedfile);
ima->packedfile = NULL;
- BLI_strncpy(ima->name, newname, sizeof(ima->name));
+ strcpy(ima->name, newname);
MEM_freeN(newname);
BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD);
}