Merged changes in the trunk up to revision 51718.
[blender.git] / source / blender / blenlib / intern / bpath.c
index d030506f4a6ef51032c5208d4d9741bbd15426ae..2f335b557fe33d63a709261bed2d0a3735c787ac 100644 (file)
 #include "BLI_bpath.h"
 #include "BLI_utildefines.h"
 
 #include "BLI_bpath.h"
 #include "BLI_utildefines.h"
 
+#include "BKE_font.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_report.h"
 #include "BKE_sequencer.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_report.h"
 #include "BKE_sequencer.h"
-#include "BKE_utildefines.h"
 #include "BKE_image.h" /* so we can check the image's type */
 
 static int checkMissingFiles_visit_cb(void *userdata, char *UNUSED(path_dst), const char *path_src)
 #include "BKE_image.h" /* so we can check the image's type */
 
 static int checkMissingFiles_visit_cb(void *userdata, char *UNUSED(path_dst), const char *path_src)
@@ -86,7 +86,7 @@ static int checkMissingFiles_visit_cb(void *userdata, char *UNUSED(path_dst), co
        ReportList *reports = (ReportList *)userdata;
 
        if (!BLI_exists(path_src)) {
        ReportList *reports = (ReportList *)userdata;
 
        if (!BLI_exists(path_src)) {
-               BKE_reportf(reports, RPT_WARNING, "Path Not Found \"%s\"", path_src);
+               BKE_reportf(reports, RPT_WARNING, "Path '%s' not found", path_src);
        }
 
        return FALSE;
        }
 
        return FALSE;
@@ -113,17 +113,17 @@ static int makeFilesRelative_visit_cb(void *userdata, char *path_dst, const char
 
        data->count_tot++;
 
 
        data->count_tot++;
 
-       if (strncmp(path_src, "//", 2) == 0) {
+       if (BLI_path_is_rel(path_src)) {
                return FALSE; /* already relative */
        }
        else {
                strcpy(path_dst, path_src);
                BLI_path_rel(path_dst, data->basedir);
                return FALSE; /* already relative */
        }
        else {
                strcpy(path_dst, path_src);
                BLI_path_rel(path_dst, data->basedir);
-               if (strncmp(path_dst, "//", 2) == 0) {
+               if (BLI_path_is_rel(path_dst)) {
                        data->count_changed++;
                }
                else {
                        data->count_changed++;
                }
                else {
-                       BKE_reportf(data->reports, RPT_WARNING, "Path cant be made relative \"%s\"", path_src);
+                       BKE_reportf(data->reports, RPT_WARNING, "Path '%s' cannot be made relative", path_src);
                        data->count_failed++;
                }
                return TRUE;
                        data->count_failed++;
                }
                return TRUE;
@@ -145,7 +145,7 @@ void BLI_bpath_relative_convert(Main *bmain, const char *basedir, ReportList *re
        BLI_bpath_traverse_main(bmain, makeFilesRelative_visit_cb, 0, (void *)&data);
 
        BKE_reportf(reports, data.count_failed ? RPT_WARNING : RPT_INFO,
        BLI_bpath_traverse_main(bmain, makeFilesRelative_visit_cb, 0, (void *)&data);
 
        BKE_reportf(reports, data.count_failed ? RPT_WARNING : RPT_INFO,
-                   "Total files %d|Changed %d|Failed %d",
+                   "Total files %d | Changed %d | Failed %d",
                    data.count_tot, data.count_changed, data.count_failed);
 }
 
                    data.count_tot, data.count_changed, data.count_failed);
 }
 
@@ -155,17 +155,17 @@ static int makeFilesAbsolute_visit_cb(void *userdata, char *path_dst, const char
 
        data->count_tot++;
 
 
        data->count_tot++;
 
-       if (strncmp(path_src, "//", 2) != 0) {
+       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);
                return FALSE; /* already absolute */
        }
        else {
                strcpy(path_dst, path_src);
                BLI_path_abs(path_dst, data->basedir);
-               if (strncmp(path_dst, "//", 2) != 0) {
+               if (BLI_path_is_rel(path_dst) == FALSE) {
                        data->count_changed++;
                }
                else {
                        data->count_changed++;
                }
                else {
-                       BKE_reportf(data->reports, RPT_WARNING, "Path cant be made absolute \"%s\"", path_src);
+                       BKE_reportf(data->reports, RPT_WARNING, "Path '%s' cannot be made absolute", path_src);
                        data->count_failed++;
                }
                return TRUE;
                        data->count_failed++;
                }
                return TRUE;
@@ -188,13 +188,13 @@ void BLI_bpath_absolute_convert(Main *bmain, const char *basedir, ReportList *re
        BLI_bpath_traverse_main(bmain, makeFilesAbsolute_visit_cb, 0, (void *)&data);
 
        BKE_reportf(reports, data.count_failed ? RPT_WARNING : RPT_INFO,
        BLI_bpath_traverse_main(bmain, makeFilesAbsolute_visit_cb, 0, (void *)&data);
 
        BKE_reportf(reports, data.count_failed ? RPT_WARNING : RPT_INFO,
-                   "Total files %d|Changed %d|Failed %d",
+                   "Total files %d | Changed %d | Failed %d",
                    data.count_tot, data.count_changed, data.count_failed);
 }
 
 /**
  * find this file recursively, use the biggest file so thumbnails don't get used by mistake
                    data.count_tot, data.count_changed, data.count_failed);
 }
 
 /**
  * find this file recursively, use the biggest file so thumbnails don't get used by mistake
- * \param filename_new: the path will be copied here, caller must initialize as empyu string.
+ * \param filename_new: the path will be copied here, caller must initialize as empty string.
  * \param dirname: subdir to search
  * \param filename: set this filename
  * \param filesize: filesize for the file
  * \param dirname: subdir to search
  * \param filename: set this filename
  * \param filesize: filesize for the file
@@ -280,13 +280,13 @@ static int findMissingFiles_visit_cb(void *userdata, char *path_dst, const char
 
        if (filesize == -1) { /* could not open dir */
                BKE_reportf(data->reports, RPT_WARNING,
 
        if (filesize == -1) { /* could not open dir */
                BKE_reportf(data->reports, RPT_WARNING,
-                           "Could open directory \"%s\"",
+                           "Could not open directory '%s'",
                            BLI_path_basename(data->searchdir));
                return FALSE;
        }
        else if (found == FALSE) {
                BKE_reportf(data->reports, RPT_WARNING,
                            BLI_path_basename(data->searchdir));
                return FALSE;
        }
        else if (found == FALSE) {
                BKE_reportf(data->reports, RPT_WARNING,
-                           "Could not find \"%s\" in \"%s\"",
+                           "Could not find '%s' in '%s'",
                            BLI_path_basename((char *)path_src), data->searchdir);
                return FALSE;
        }
                            BLI_path_basename((char *)path_src), data->searchdir);
                return FALSE;
        }
@@ -485,9 +485,9 @@ void BLI_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
                        break;
                case ID_VF:
                {
                        break;
                case ID_VF:
                {
-                       VFont *vf = (VFont *)id;
-                       if (vf->packedfile == NULL || (flag & BLI_BPATH_TRAVERSE_SKIP_PACKED) == 0) {
-                               if (strcmp(vf->name, FO_BUILTIN_NAME) != 0) {
+                       VFont *vfont = (VFont *)id;
+                       if (vfont->packedfile == NULL || (flag & BLI_BPATH_TRAVERSE_SKIP_PACKED) == 0) {
+                               if (BKE_vfont_is_builtin(vfont) == FALSE) {
                                        rewrite_path_fixed(((VFont *)id)->name, visit_cb, absbase, bpath_user_data);
                                }
                        }
                                        rewrite_path_fixed(((VFont *)id)->name, visit_cb, absbase, bpath_user_data);
                                }
                        }
@@ -552,8 +552,8 @@ void BLI_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
                case ID_ME:
                {
                        Mesh *me = (Mesh *)id;
                case ID_ME:
                {
                        Mesh *me = (Mesh *)id;
-                       if (me->fdata.external) {
-                               rewrite_path_fixed(me->fdata.external->filename, visit_cb, absbase, bpath_user_data);
+                       if (me->ldata.external) {
+                               rewrite_path_fixed(me->ldata.external->filename, visit_cb, absbase, bpath_user_data);
                        }
                }
                break;
                        }
                }
                break;
@@ -603,7 +603,7 @@ int BLI_bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *pat
        const char *base_new = ((char **)pathbase_v)[0];
        const char *base_old = ((char **)pathbase_v)[1];
 
        const char *base_new = ((char **)pathbase_v)[0];
        const char *base_old = ((char **)pathbase_v)[1];
 
-       if (strncmp(base_old, "//", 2) == 0) {
+       if (BLI_path_is_rel(base_old)) {
                printf("%s: error, old base path '%s' is not absolute.\n",
                       __func__, base_old);
                return FALSE;
                printf("%s: error, old base path '%s' is not absolute.\n",
                       __func__, base_old);
                return FALSE;