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:
authorCampbell Barton <ideasman42@gmail.com>2012-01-31 22:00:41 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-01-31 22:00:41 +0400
commit23db21e2c17052ba756a68eb7450fedacc14c555 (patch)
tree49e203525cc87dc8e41f564a28d25bcbcd0e6b14 /source/blender/blenlib/intern/bpath.c
parent58646f10a17ca72fb55841084375ba6bcfdaef2a (diff)
fix own error [#29634] 'Find Missing Files' breaks good links
Diffstat (limited to 'source/blender/blenlib/intern/bpath.c')
-rw-r--r--source/blender/blenlib/intern/bpath.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c
index 861efcfe6c5..fdda9166c94 100644
--- a/source/blender/blenlib/intern/bpath.c
+++ b/source/blender/blenlib/intern/bpath.c
@@ -194,10 +194,12 @@ void makeFilesAbsolute(Main *bmain, const char *basedir, ReportList *reports)
/* find this file recursively, use the biggest file so thumbnails dont get used by mistake
- - dir: subdir to search
- - filename: set this filename
- - filesize: filesize for the file
-*/
+ * - dir: subdir to search
+ * - filename: set this filename
+ * - filesize: filesize for the file
+ *
+ * return found: 1/0.
+ */
#define MAX_RECUR 16
static int findFileRecursive(char *filename_new,
const char *dirname,
@@ -211,11 +213,14 @@ static int findFileRecursive(char *filename_new,
struct stat status;
char path[FILE_MAX];
int size;
+ int found = FALSE;
+
+ filename_new[0] = '\0';
dir= opendir(dirname);
if (dir==NULL)
- return 0;
+ return found;
if (*filesize == -1)
*filesize= 0; /* dir opened fine */
@@ -237,19 +242,20 @@ static int findFileRecursive(char *filename_new,
if ((size > 0) && (size > *filesize)) { /* find the biggest file */
*filesize= size;
BLI_strncpy(filename_new, path, FILE_MAX);
+ found = TRUE;
}
}
}
else if (S_ISDIR(status.st_mode)) { /* is subdir */
if (*recur_depth <= MAX_RECUR) {
(*recur_depth)++;
- findFileRecursive(filename_new, path, filename, filesize, recur_depth);
+ found |= findFileRecursive(filename_new, path, filename, filesize, recur_depth);
(*recur_depth)--;
}
}
}
closedir(dir);
- return 1;
+ return found;
}
typedef struct BPathFind_Data
@@ -266,19 +272,26 @@ static int findMissingFiles_visit_cb(void *userdata, char *path_dst, const char
int filesize= -1;
int recur_depth= 0;
+ int found;
- findFileRecursive(filename_new,
- data->searchdir, BLI_path_basename((char *)path_src),
- &filesize, &recur_depth);
+ found = findFileRecursive(filename_new,
+ data->searchdir, BLI_path_basename((char *)path_src),
+ &filesize, &recur_depth);
if (filesize == -1) { /* could not open dir */
BKE_reportf(data->reports, RPT_WARNING,
+ "Could open directory \"%s\"",
+ BLI_path_basename(data->searchdir));
+ return FALSE;
+ }
+ else if (found == FALSE) {
+ BKE_reportf(data->reports, RPT_WARNING,
"Could not find \"%s\" in \"%s\"",
BLI_path_basename((char *)path_src), data->searchdir);
return FALSE;
}
else {
- strcpy(path_dst, filename_new);
+ BLI_strncpy(path_dst, filename_new, FILE_MAX);
return TRUE;
}
}