Merge branch 'master' into blender2.8
[blender.git] / source / blender / blenkernel / intern / bpath.c
index 0d44f5cad6fda17985fbc59c964e6c49f7b1c91a..f3ff0f253e53dfbe55335c38a07385ba839d416d 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
  * Contributor(s): Campbell barton, Alex Fraser
  *
  * ***** END GPL LICENSE BLOCK *****
@@ -60,7 +55,6 @@
 #include "DNA_object_fluidsim.h"
 #include "DNA_object_force.h"
 #include "DNA_object_types.h"
-#include "DNA_particle_types.h"
 #include "DNA_sequence_types.h"
 #include "DNA_sound_types.h"
 #include "DNA_text_types.h"
@@ -70,9 +64,7 @@
 #include "DNA_vfont_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_smoke_types.h"
-#ifdef WITH_FREESTYLE
-#  include "DNA_freestyle_types.h"
-#endif
+#include "DNA_freestyle_types.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_utildefines.h"
 #include "BKE_node.h"
 #include "BKE_report.h"
 #include "BKE_sequencer.h"
-#include "BKE_image.h" /* so we can check the image's type */
+#include "BKE_image.h"
 
 #include "BKE_bpath.h"  /* own include */
 
-static int checkMissingFiles_visit_cb(void *userdata, char *UNUSED(path_dst), const char *path_src)
+#ifndef _MSC_VER
+#  include "BLI_strict_flags.h"
+#endif
+
+static bool checkMissingFiles_visit_cb(void *userdata, char *UNUSED(path_dst), const char *path_src)
 {
        ReportList *reports = (ReportList *)userdata;
 
@@ -95,13 +91,14 @@ static int checkMissingFiles_visit_cb(void *userdata, char *UNUSED(path_dst), co
                BKE_reportf(reports, RPT_WARNING, "Path '%s' not found", path_src);
        }
 
-       return FALSE;
+       return false;
 }
 
 /* high level function */
 void BKE_bpath_missing_files_check(Main *bmain, ReportList *reports)
 {
-       BKE_bpath_traverse_main(bmain, checkMissingFiles_visit_cb, BKE_BPATH_TRAVERSE_ABS, reports);
+       BKE_bpath_traverse_main(bmain, checkMissingFiles_visit_cb,
+                               BKE_BPATH_TRAVERSE_ABS | BKE_BPATH_TRAVERSE_SKIP_PACKED, reports);
 }
 
 typedef struct BPathRemap_Data {
@@ -113,14 +110,14 @@ typedef struct BPathRemap_Data {
        int count_failed;
 } BPathRemap_Data;
 
-static int makeFilesRelative_visit_cb(void *userdata, char *path_dst, const char *path_src)
+static bool bpath_relative_convert_visit_cb(void *userdata, char *path_dst, const char *path_src)
 {
        BPathRemap_Data *data = (BPathRemap_Data *)userdata;
 
        data->count_tot++;
 
        if (BLI_path_is_rel(path_src)) {
-               return FALSE; /* already relative */
+               return false; /* already relative */
        }
        else {
                strcpy(path_dst, path_src);
@@ -132,13 +129,14 @@ static int makeFilesRelative_visit_cb(void *userdata, char *path_dst, const char
                        BKE_reportf(data->reports, RPT_WARNING, "Path '%s' cannot be made relative", path_src);
                        data->count_failed++;
                }
-               return TRUE;
+               return true;
        }
 }
 
 void BKE_bpath_relative_convert(Main *bmain, const char *basedir, ReportList *reports)
 {
        BPathRemap_Data data = {NULL};
+       const int flag = BKE_BPATH_TRAVERSE_SKIP_LIBRARY;
 
        if (basedir[0] == '\0') {
                printf("%s: basedir='', this is a bug\n", __func__);
@@ -148,33 +146,33 @@ void BKE_bpath_relative_convert(Main *bmain, const char *basedir, ReportList *re
        data.basedir = basedir;
        data.reports = reports;
 
-       BKE_bpath_traverse_main(bmain, makeFilesRelative_visit_cb, 0, (void *)&data);
+       BKE_bpath_traverse_main(bmain, bpath_relative_convert_visit_cb, flag, (void *)&data);
 
        BKE_reportf(reports, data.count_failed ? RPT_WARNING : RPT_INFO,
                    "Total files %d | Changed %d | Failed %d",
                    data.count_tot, data.count_changed, data.count_failed);
 }
 
-static int makeFilesAbsolute_visit_cb(void *userdata, char *path_dst, const char *path_src)
+static bool bpath_absolute_convert_visit_cb(void *userdata, char *path_dst, const char *path_src)
 {
        BPathRemap_Data *data = (BPathRemap_Data *)userdata;
 
        data->count_tot++;
 
-       if (BLI_path_is_rel(path_src) == FALSE) {
-               return FALSE; /* already absolute */
+       if (BLI_path_is_rel(path_src) == false) {
+               return false; /* already absolute */
        }
        else {
                strcpy(path_dst, path_src);
                BLI_path_abs(path_dst, data->basedir);
-               if (BLI_path_is_rel(path_dst) == FALSE) {
+               if (BLI_path_is_rel(path_dst) == false) {
                        data->count_changed++;
                }
                else {
                        BKE_reportf(data->reports, RPT_WARNING, "Path '%s' cannot be made absolute", path_src);
                        data->count_failed++;
                }
-               return TRUE;
+               return true;
        }
 }
 
@@ -182,6 +180,7 @@ static int makeFilesAbsolute_visit_cb(void *userdata, char *path_dst, const char
 void BKE_bpath_absolute_convert(Main *bmain, const char *basedir, ReportList *reports)
 {
        BPathRemap_Data data = {NULL};
+       const int flag = BKE_BPATH_TRAVERSE_SKIP_LIBRARY;
 
        if (basedir[0] == '\0') {
                printf("%s: basedir='', this is a bug\n", __func__);
@@ -191,7 +190,7 @@ void BKE_bpath_absolute_convert(Main *bmain, const char *basedir, ReportList *re
        data.basedir = basedir;
        data.reports = reports;
 
-       BKE_bpath_traverse_main(bmain, makeFilesAbsolute_visit_cb, 0, (void *)&data);
+       BKE_bpath_traverse_main(bmain, bpath_absolute_convert_visit_cb, flag, (void *)&data);
 
        BKE_reportf(reports, data.count_failed ? RPT_WARNING : RPT_INFO,
                    "Total files %d | Changed %d | Failed %d",
@@ -208,54 +207,55 @@ 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;
-       struct stat status;
+       BLI_stat_t status;
        char path[FILE_MAX];
-       int size;
-       int found = FALSE;
+       off_t size;
+       bool found = false;
 
        dir = opendir(dirname);
 
        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) {
 
-               if (strcmp(".", de->d_name) == 0 || strcmp("..", de->d_name) == 0)
+               if (FILENAME_IS_CURRPAR(de->d_name))
                        continue;
 
                BLI_join_dirfile(path, sizeof(path), dirname, de->d_name);
 
-               if (stat(path, &status) != 0)
+               if (BLI_stat(path, &status) == -1)
                        continue;  /* cant stat, don't bother with this file, could print debug info here */
 
                if (S_ISREG(status.st_mode)) { /* is file */
-                       if (strncmp(filename, de->d_name, FILE_MAX) == 0) { /* name matches */
+                       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;
+                                       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)--;
                        }
                }
        }
@@ -265,55 +265,74 @@ static int findFileRecursive(char *filename_new,
 
 typedef struct BPathFind_Data {
        const char *basedir;
-       char searchdir[FILE_MAX];
+       const char *searchdir;
        ReportList *reports;
+       bool find_all;
 } BPathFind_Data;
 
-static int 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)) {
+                       return false;
+               }
+       }
 
        filename_new[0] = '\0';
 
-       found = findFileRecursive(filename_new,
-                                 data->searchdir, BLI_path_basename((char *)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,
                            "Could not open directory '%s'",
                            BLI_path_basename(data->searchdir));
-               return FALSE;
+               return false;
        }
-       else if (found == 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;
+                           BLI_path_basename(path_src), data->searchdir);
+               return false;
        }
        else {
+               bool was_relative = BLI_path_is_rel(path_dst);
+
                BLI_strncpy(path_dst, filename_new, FILE_MAX);
-               return TRUE;
+
+               /* keep path relative if the previous one was relative */
+               if (was_relative)
+                       BLI_path_rel(path_dst, data->basedir);
+
+               return true;
        }
 }
 
-void BKE_bpath_missing_files_find(Main *bmain, const char *searchpath, ReportList *reports)
+void BKE_bpath_missing_files_find(Main *bmain, const char *searchpath, ReportList *reports,
+                                  const bool find_all)
 {
        struct BPathFind_Data data = {NULL};
+       const int flag = BKE_BPATH_TRAVERSE_ABS | BKE_BPATH_TRAVERSE_RELOAD_EDITED;
 
+       data.basedir = bmain->name;
        data.reports = reports;
-       BLI_split_dir_part(searchpath, data.searchdir, sizeof(data.searchdir));
+       data.searchdir = searchpath;
+       data.find_all = find_all;
 
-       BKE_bpath_traverse_main(bmain, findMissingFiles_visit_cb, 0, (void *)&data);
+       BKE_bpath_traverse_main(bmain, missing_files_find__visit_cb, flag, (void *)&data);
 }
 
 /* Run a visitor on a string, replacing the contents of the string as needed. */
-static int rewrite_path_fixed(char *path, BPathVisitor visit_cb, const char *absbase, void *userdata)
+static bool rewrite_path_fixed(char *path, BPathVisitor visit_cb, const char *absbase, void *userdata)
 {
        char path_src_buf[FILE_MAX];
        const char *path_src;
@@ -328,40 +347,46 @@ static int rewrite_path_fixed(char *path, BPathVisitor visit_cb, const char *abs
                path_src = path;
        }
 
+       /* so functions can check old value */
+       BLI_strncpy(path_dst, path, FILE_MAX);
+
        if (visit_cb(userdata, path_dst, path_src)) {
                BLI_strncpy(path, path_dst, FILE_MAX);
-               return TRUE;
+               return true;
        }
        else {
-               return FALSE;
+               return false;
        }
 }
 
-static int rewrite_path_fixed_dirfile(char path_dir[FILE_MAXDIR],
-                                      char path_file[FILE_MAXFILE],
-                                      BPathVisitor visit_cb,
-                                      const char *absbase,
-                                      void *userdata)
+static bool rewrite_path_fixed_dirfile(char path_dir[FILE_MAXDIR],
+                                       char path_file[FILE_MAXFILE],
+                                       BPathVisitor visit_cb,
+                                       const char *absbase,
+                                       void *userdata)
 {
        char path_src[FILE_MAX];
        char path_dst[FILE_MAX];
 
        BLI_join_dirfile(path_src, sizeof(path_src), path_dir, path_file);
 
+       /* so functions can check old value */
+       BLI_strncpy(path_dst, path_src, FILE_MAX);
+
        if (absbase) {
                BLI_path_abs(path_src, absbase);
        }
 
        if (visit_cb(userdata, path_dst, (const char *)path_src)) {
                BLI_split_dirfile(path_dst, path_dir, path_file, FILE_MAXDIR, FILE_MAXFILE);
-               return TRUE;
+               return true;
        }
        else {
-               return FALSE;
+               return false;
        }
 }
 
-static int rewrite_path_alloc(char **path, BPathVisitor visit_cb, const char *absbase, void *userdata)
+static bool rewrite_path_alloc(char **path, BPathVisitor visit_cb, const char *absbase, void *userdata)
 {
        char path_src_buf[FILE_MAX];
        const char *path_src;
@@ -377,21 +402,28 @@ static int rewrite_path_alloc(char **path, BPathVisitor visit_cb, const char *ab
        }
 
        if (visit_cb(userdata, path_dst, path_src)) {
-               MEM_freeN((*path));
+               MEM_freeN(*path);
                (*path) = BLI_strdup(path_dst);
-               return TRUE;
+               return true;
        }
        else {
-               return FALSE;
+               return false;
        }
 }
 
+/* fix the image user "ok" tag after updating paths, so ImBufs get loaded */
+static void bpath_traverse_image_user_cb(Image *ima, ImageUser *iuser, void *customdata)
+{
+       if (ima == customdata)
+               iuser->ok = 1;
+}
+
 /* Run visitor function 'visit' on all paths contained in 'id'. */
 void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int flag, void *bpath_user_data)
 {
        const char *absbase = (flag & BKE_BPATH_TRAVERSE_ABS) ? ID_BLEND_PATH(bmain, id) : NULL;
 
-       if ((flag & BKE_BPATH_TRAVERSE_SKIP_LIBRARY) && id->lib) {
+       if ((flag & BKE_BPATH_TRAVERSE_SKIP_LIBRARY) && ID_IS_LINKED_DATABLOCK(id)) {
                return;
        }
 
@@ -400,9 +432,19 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
                {
                        Image *ima;
                        ima = (Image *)id;
-                       if (ima->packedfile == NULL || (flag & BKE_BPATH_TRAVERSE_SKIP_PACKED) == 0) {
-                               if (ELEM3(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
-                                       rewrite_path_fixed(ima->name, visit_cb, absbase, bpath_user_data);
+                       if (BKE_image_has_packedfile(ima) == false || (flag & BKE_BPATH_TRAVERSE_SKIP_PACKED) == 0) {
+                               if (ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
+                                       if (rewrite_path_fixed(ima->name, visit_cb, absbase, bpath_user_data)) {
+                                               if (flag & BKE_BPATH_TRAVERSE_RELOAD_EDITED) {
+                                                       if (!BKE_image_has_packedfile(ima) &&
+                                                           /* image may have been painted onto (and not saved, T44543) */
+                                                           !BKE_image_is_dirty(ima))
+                                                       {
+                                                               BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD);
+                                                               BKE_image_walk_all_users(bmain, ima, bpath_traverse_image_user_cb);
+                                                       }
+                                               }
+                                       }
                                }
                        }
                        break;
@@ -419,20 +461,6 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
                {
                        Object *ob = (Object *)id;
                        ModifierData *md;
-                       ParticleSystem *psys;
-
-#define BPATH_TRAVERSE_POINTCACHE(ptcaches)                                    \
-       {                                                                          \
-               PointCache *cache;                                                     \
-               for (cache = (ptcaches).first; cache; cache = cache->next) {           \
-                       if (cache->flag & PTCACHE_DISK_CACHE) {                            \
-                               rewrite_path_fixed(cache->path,                                \
-                                                  visit_cb,                                   \
-                                                  absbase,                                    \
-                                                  bpath_user_data);                           \
-                       }                                                                  \
-               }                                                                      \
-       } (void)0
 
                        /* do via modifiers instead */
 #if 0
@@ -448,32 +476,16 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
                                                rewrite_path_fixed(fluidmd->fss->surfdataPath, visit_cb, absbase, bpath_user_data);
                                        }
                                }
-                               else if (md->type == eModifierType_Smoke) {
-                                       SmokeModifierData *smd = (SmokeModifierData *)md;
-                                       if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
-                                               BPATH_TRAVERSE_POINTCACHE(smd->domain->ptcaches[0]);
-                                       }
-                               }
-                               else if (md->type == eModifierType_Cloth) {
-                                       ClothModifierData *clmd = (ClothModifierData *) md;
-                                       BPATH_TRAVERSE_POINTCACHE(clmd->ptcaches);
-                               }
                                else if (md->type == eModifierType_Ocean) {
                                        OceanModifierData *omd = (OceanModifierData *) md;
                                        rewrite_path_fixed(omd->cachepath, visit_cb, absbase, bpath_user_data);
                                }
+                               else if (md->type == eModifierType_MeshCache) {
+                                       MeshCacheModifierData *mcmd = (MeshCacheModifierData *) md;
+                                       rewrite_path_fixed(mcmd->filepath, visit_cb, absbase, bpath_user_data);
+                               }
                        }
 
-                       if (ob->soft) {
-                               BPATH_TRAVERSE_POINTCACHE(ob->soft->ptcaches);
-                       }
-
-                       for (psys = ob->particlesystem.first; psys; psys = psys->next) {
-                               BPATH_TRAVERSE_POINTCACHE(psys->ptcaches);
-                       }
-
-#undef BPATH_TRAVERSE_POINTCACHE
-
                        break;
                }
                case ID_SO:
@@ -493,7 +505,7 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
                {
                        VFont *vfont = (VFont *)id;
                        if (vfont->packedfile == NULL || (flag & BKE_BPATH_TRAVERSE_SKIP_PACKED) == 0) {
-                               if (BKE_vfont_is_builtin(vfont) == FALSE) {
+                               if (BKE_vfont_is_builtin(vfont) == false) {
                                        rewrite_path_fixed(((VFont *)id)->name, visit_cb, absbase, bpath_user_data);
                                }
                        }
@@ -549,19 +561,20 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
                                SEQ_BEGIN(scene->ed, seq)
                                {
                                        if (SEQ_HAS_PATH(seq)) {
-                                               if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM)) {
-                                                       rewrite_path_fixed_dirfile(seq->strip->dir, seq->strip->stripdata->name,
+                                               StripElem *se = seq->strip->stripdata;
+
+                                               if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM) && se) {
+                                                       rewrite_path_fixed_dirfile(seq->strip->dir, se->name,
                                                                                   visit_cb, absbase, bpath_user_data);
                                                }
-                                               else if (seq->type == SEQ_TYPE_IMAGE) {
+                                               else if ((seq->type == SEQ_TYPE_IMAGE) && se) {
                                                        /* might want an option not to loop over all strips */
-                                                       StripElem *se = seq->strip->stripdata;
-                                                       int len = MEM_allocN_len(se) / sizeof(*se);
-                                                       int i;
+                                                       unsigned int len = (unsigned int)MEM_allocN_len(se) / (unsigned int)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++) {
@@ -578,18 +591,6 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
                                }
                                SEQ_END
                        }
-#ifdef WITH_FREESTYLE
-                       {
-                               SceneRenderLayer *srl = scene->r.layers.first;
-
-                               for(; srl; srl = srl->next) {
-                                       FreestyleModuleConfig* module = srl->freestyleConfig.modules.first;
-                                       for (; module; module = module->next) {
-                                               rewrite_path_fixed(module->module_path, visit_cb, absbase, bpath_user_data);
-                                       }
-                               }
-                       }
-#endif
                        break;
                }
                case ID_ME:
@@ -603,8 +604,11 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
                case ID_LI:
                {
                        Library *lib = (Library *)id;
-                       if (rewrite_path_fixed(lib->name, visit_cb, absbase, bpath_user_data)) {
-                               BKE_library_filepath_set(lib, lib->name);
+                       /* keep packedfile paths always relative to the blend */
+                       if (lib->packedfile == NULL) {
+                               if (rewrite_path_fixed(lib->name, visit_cb, absbase, bpath_user_data)) {
+                                       BKE_library_filepath_set(lib, lib->name);
+                               }
                        }
                        break;
                }
@@ -639,7 +643,7 @@ void BKE_bpath_traverse_main(Main *bmain, BPathVisitor visit_cb, const int flag,
 
 /* Rewrites a relative path to be relative to the main file - unless the path is
  * absolute, in which case it is not altered. */
-int BKE_bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *path_src)
+bool BKE_bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *path_src)
 {
        /* be sure there is low chance of the path being too short */
        char filepath[(FILE_MAXDIR * 2) + FILE_MAXFILE];
@@ -649,7 +653,7 @@ int BKE_bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *pat
        if (BLI_path_is_rel(base_old)) {
                printf("%s: error, old base path '%s' is not absolute.\n",
                       __func__, base_old);
-               return FALSE;
+               return false;
        }
 
        /* Make referenced file absolute. This would be a side-effect of
@@ -662,11 +666,11 @@ int BKE_bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *pat
                BLI_cleanup_file(base_new, filepath);
                BLI_path_rel(filepath, base_new);
                BLI_strncpy(path_dst, filepath, FILE_MAX);
-               return TRUE;
+               return true;
        }
        else {
                /* Path was not relative to begin with. */
-               return FALSE;
+               return false;
        }
 }
 
@@ -674,41 +678,41 @@ int BKE_bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *pat
 /* -------------------------------------------------------------------- */
 /**
  * Backup/Restore/Free functions,
- * \note These functions assume the data won't chane order.
+ * \note These functions assume the data won't change order.
  */
 
 struct PathStore {
        struct PathStore *next, *prev;
-} PathStore;
+};
 
-static int bpath_list_append(void *userdata, char *UNUSED(path_dst), const char *path_src)
+static bool bpath_list_append(void *userdata, char *UNUSED(path_dst), const char *path_src)
 {
        /* store the path and string in a single alloc */
        ListBase *ls = userdata;
        size_t path_size = strlen(path_src) + 1;
-       struct PathStore *path_store = MEM_mallocN(sizeof(PathStore) + path_size, __func__);
+       struct PathStore *path_store = MEM_mallocN(sizeof(struct PathStore) + path_size, __func__);
        char *filepath = (char *)(path_store + 1);
 
        memcpy(filepath, path_src, path_size);
        BLI_addtail(ls, path_store);
-       return FALSE;
+       return false;
 }
 
-static int bpath_list_restore(void *userdata, char *path_dst, const char *path_src)
+static bool bpath_list_restore(void *userdata, char *path_dst, const char *path_src)
 {
        /* assume ls->first wont be NULL because the number of paths can't change!
         * (if they do caller is wrong) */
        ListBase *ls = userdata;
        struct PathStore *path_store = ls->first;
        const char *filepath = (char *)(path_store + 1);
-       int ret;
+       bool ret;
 
-       if (strcmp(path_src, filepath) == 0) {
-               ret = FALSE;
+       if (STREQ(path_src, filepath)) {
+               ret = false;
        }
        else {
                BLI_strncpy(path_dst, filepath, FILE_MAX);
-               ret = TRUE;
+               ret = true;
        }
 
        BLI_freelinkN(ls, path_store);
@@ -735,7 +739,7 @@ void BKE_bpath_list_restore(Main *bmain, const int flag, void *ls_handle)
 void BKE_bpath_list_free(void *ls_handle)
 {
        ListBase *ls = ls_handle;
-       BLI_assert(ls->first == NULL);  /* assumes we were used */
+       BLI_assert(BLI_listbase_is_empty(ls));  /* assumes we were used */
        BLI_freelistN(ls);
        MEM_freeN(ls);
 }