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>2015-04-10 15:01:10 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-04-10 15:06:28 +0300
commitec710775cfb314abdd501873aa9f5e790b1c06b6 (patch)
tree7138f93bc4d18128de14c1fe0a5fc422bdb268d7 /source/blender/blenkernel/intern/bpath.c
parentb0906bcc5e1b5ce7049e0b72fcfc0d0916c20563 (diff)
Use off_t for filesize (was int)
Resolves finding >2gig files. Also enable strict flags.
Diffstat (limited to 'source/blender/blenkernel/intern/bpath.c')
-rw-r--r--source/blender/blenkernel/intern/bpath.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c
index bb3731218ed..2b3261fa4a7 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -80,6 +80,8 @@
#include "BKE_bpath.h" /* own include */
+#include "BLI_strict_flags.h"
+
static bool checkMissingFiles_visit_cb(void *userdata, char *UNUSED(path_dst), const char *path_src)
{
ReportList *reports = (ReportList *)userdata;
@@ -204,18 +206,19 @@ void BKE_bpath_absolute_convert(Main *bmain, const char *basedir, ReportList *re
* \returns found: 1/0.
*/
#define MAX_RECUR 16
-static int findFileRecursive(char *filename_new,
- const char *dirname,
- const char *filename,
- int *filesize,
- int *recur_depth)
+static bool missing_files_find__recursive(
+ char *filename_new,
+ const char *dirname,
+ const char *filename,
+ off_t *r_filesize,
+ int *r_recur_depth)
{
/* file searching stuff */
DIR *dir;
struct dirent *de;
BLI_stat_t status;
char path[FILE_MAX];
- int size;
+ off_t size;
bool found = false;
dir = opendir(dirname);
@@ -223,8 +226,8 @@ static int findFileRecursive(char *filename_new,
if (dir == NULL)
return found;
- if (*filesize == -1)
- *filesize = 0; /* dir opened fine */
+ if (*r_filesize == -1)
+ *r_filesize = 0; /* dir opened fine */
while ((de = readdir(dir)) != NULL) {
@@ -240,18 +243,18 @@ static int findFileRecursive(char *filename_new,
if (STREQLEN(filename, de->d_name, FILE_MAX)) { /* name matches */
/* open the file to read its size */
size = status.st_size;
- if ((size > 0) && (size > *filesize)) { /* find the biggest file */
- *filesize = size;
+ if ((size > 0) && (size > *r_filesize)) { /* find the biggest file */
+ *r_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)++;
- found |= findFileRecursive(filename_new, path, filename, filesize, recur_depth);
- (*recur_depth)--;
+ if (*r_recur_depth <= MAX_RECUR) {
+ (*r_recur_depth)++;
+ found |= missing_files_find__recursive(filename_new, path, filename, r_filesize, r_recur_depth);
+ (*r_recur_depth)--;
}
}
}
@@ -266,14 +269,14 @@ typedef struct BPathFind_Data {
bool find_all;
} BPathFind_Data;
-static bool findMissingFiles_visit_cb(void *userdata, char *path_dst, const char *path_src)
+static bool missing_files_find__visit_cb(void *userdata, char *path_dst, const char *path_src)
{
BPathFind_Data *data = (BPathFind_Data *)userdata;
char filename_new[FILE_MAX];
- int filesize = -1;
+ off_t filesize = -1;
int recur_depth = 0;
- int found;
+ bool found;
if (data->find_all == false) {
if (BLI_exists(path_src)) {
@@ -283,9 +286,10 @@ static bool findMissingFiles_visit_cb(void *userdata, char *path_dst, const char
filename_new[0] = '\0';
- found = findFileRecursive(filename_new,
- data->searchdir, BLI_path_basename(path_src),
- &filesize, &recur_depth);
+ found = missing_files_find__recursive(
+ filename_new,
+ data->searchdir, BLI_path_basename(path_src),
+ &filesize, &recur_depth);
if (filesize == -1) { /* could not open dir */
BKE_reportf(data->reports, RPT_WARNING,
@@ -322,7 +326,7 @@ void BKE_bpath_missing_files_find(Main *bmain, const char *searchpath, ReportLis
data.searchdir = searchpath;
data.find_all = find_all;
- BKE_bpath_traverse_main(bmain, findMissingFiles_visit_cb, BKE_BPATH_TRAVERSE_ABS, (void *)&data);
+ BKE_bpath_traverse_main(bmain, missing_files_find__visit_cb, BKE_BPATH_TRAVERSE_ABS, (void *)&data);
}
/* Run a visitor on a string, replacing the contents of the string as needed. */
@@ -589,12 +593,12 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
}
else if ((seq->type == SEQ_TYPE_IMAGE) && se) {
/* might want an option not to loop over all strips */
- int len = MEM_allocN_len(se) / sizeof(*se);
- int i;
+ unsigned int len = (unsigned int)MEM_allocN_len(se) / sizeof(*se);
+ unsigned int i;
if (flag & BKE_BPATH_TRAVERSE_SKIP_MULTIFILE) {
/* only operate on one path */
- len = MIN2(1, len);
+ len = MIN2(1u, len);
}
for (i = 0; i < len; i++, se++) {