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:
-rw-r--r--source/blender/blenkernel/intern/library.c2
-rw-r--r--source/blender/blenkernel/intern/pointcache.c3
-rw-r--r--source/blender/blenlib/BLI_path_util.h2
-rw-r--r--source/blender/blenlib/intern/bpath.c10
-rw-r--r--source/blender/blenlib/intern/path_util.c15
-rw-r--r--source/blender/blenloader/intern/readfile.c4
-rw-r--r--source/blender/editors/space_file/file_ops.c2
-rw-r--r--source/blender/editors/space_image/image_ops.c2
8 files changed, 26 insertions, 14 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index e073cfdf76d..9f770e0a9a7 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -1528,7 +1528,7 @@ void BKE_library_filepath_set(Library *lib, const char *filepath)
/* not essential but set filepath is an absolute copy of value which
* is more useful if its kept in sync */
- if (strncmp(lib->filepath, "//", 2) == 0) {
+ if (BLI_path_is_rel(lib->filepath)) {
/* note that the file may be unsaved, in this case, setting the
* filepath on an indirectly linked path is not allowed from the
* outliner, and its not really supported but allow from here for now
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index e990f461d4c..1588ec10b55 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -1067,8 +1067,9 @@ static int ptcache_path(PTCacheID *pid, char *filename)
if (pid->cache->flag & PTCACHE_EXTERNAL) {
strcpy(filename, pid->cache->path);
- if (strncmp(filename, "//", 2)==0)
+ if (BLI_path_is_rel(filename)) {
BLI_path_abs(filename, blendfilename);
+ }
return BLI_add_slash(filename); /* new strlen() */
}
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index 9b68406cc54..35d7b8d9444 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -154,6 +154,8 @@ int BLI_path_frame_range(char *path, int sta, int end, int digits);
int BLI_path_cwd(char *path);
void BLI_path_rel(char *file, const char *relfile);
+int BLI_path_is_rel(const char *path);
+
#ifdef WIN32
# define BLI_path_cmp BLI_strcasecmp
# define BLI_path_ncmp BLI_strncasecmp
diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c
index 6d95b078340..2a750cb1a66 100644
--- a/source/blender/blenlib/intern/bpath.c
+++ b/source/blender/blenlib/intern/bpath.c
@@ -113,13 +113,13 @@ static int makeFilesRelative_visit_cb(void *userdata, char *path_dst, const char
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);
- if (strncmp(path_dst, "//", 2) == 0) {
+ if (BLI_path_is_rel(path_dst)) {
data->count_changed++;
}
else {
@@ -155,13 +155,13 @@ static int makeFilesAbsolute_visit_cb(void *userdata, char *path_dst, const char
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);
- if (strncmp(path_dst, "//", 2) != 0) {
+ if (BLI_path_is_rel(path_dst) == FALSE) {
data->count_changed++;
}
else {
@@ -596,7 +596,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];
- 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;
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 22b160ad0b4..e6ecdeae2e9 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -411,6 +411,11 @@ void BLI_cleanup_file(const char *relabase, char *dir)
BLI_del_slash(dir);
}
+int BLI_path_is_rel(const char *path)
+{
+ return path[0] == '/' && path[1] == '/';
+}
+
void BLI_path_rel(char *file, const char *relfile)
{
char *lslash;
@@ -418,10 +423,14 @@ void BLI_path_rel(char *file, const char *relfile)
char res[FILE_MAX];
/* if file is already relative, bail out */
- if (file[0] == '/' && file[1] == '/') return;
+ if (BLI_path_is_rel(file)) {
+ return;
+ }
/* also bail out if relative path is not set */
- if (relfile[0] == 0) return;
+ if (relfile[0] == '\0') {
+ return;
+ }
#ifdef WIN32
if (BLI_strnlen(relfile, 3) > 2 && relfile[1] != ':') {
@@ -630,7 +639,7 @@ int BLI_path_frame_range(char *path, int sta, int end, int digits)
int BLI_path_abs(char *path, const char *basepath)
{
- int wasrelative = (strncmp(path, "//", 2) == 0);
+ int wasrelative = BLI_path_is_rel(path);
char tmp[FILE_MAX];
char base[FILE_MAX];
#ifdef WIN32
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index e6b97f1b2ff..ac792a90735 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6109,7 +6109,7 @@ static void fix_relpaths_library(const char *basepath, Main *main)
* it absolute. This can happen when appending an object with a relative
* link into an unsaved blend file. See [#27405].
* The remap relative option will make it relative again on save - campbell */
- if (strncmp(lib->name, "//", 2) == 0) {
+ if (BLI_path_is_rel(lib->name)) {
BLI_strncpy(lib->name, lib->filepath, sizeof(lib->name));
}
}
@@ -6118,7 +6118,7 @@ static void fix_relpaths_library(const char *basepath, Main *main)
for (lib = main->library.first; lib; lib = lib->id.next) {
/* Libraries store both relative and abs paths, recreate relative paths,
* relative to the blend file since indirectly linked libs will be relative to their direct linked library */
- if (strncmp(lib->name, "//", 2) == 0) { /* if this is relative to begin with? */
+ if (BLI_path_is_rel(lib->name)) { /* if this is relative to begin with? */
BLI_strncpy(lib->name, lib->filepath, sizeof(lib->name));
BLI_path_rel(lib->name, basepath);
}
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index ff7a71af8c2..878858c1acd 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -1113,7 +1113,7 @@ static void file_expand_directory(bContext *C)
if (sfile->params) {
/* TODO, what about // when relbase isn't valid? */
- if (G.relbase_valid && strncmp(sfile->params->dir, "//", 2) == 0) {
+ if (G.relbase_valid && BLI_path_is_rel(sfile->params->dir)) {
BLI_path_abs(sfile->params->dir, G.main->name);
}
else if (sfile->params->dir[0] == '~') {
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 855f92720e8..3eeae1f16de 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1051,7 +1051,7 @@ static int image_replace_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve
return image_replace_exec(C, op);
if (!RNA_struct_property_is_set(op->ptr, "relative_path"))
- RNA_boolean_set(op->ptr, "relative_path", (strncmp(sima->image->name, "//", 2)) == 0);
+ RNA_boolean_set(op->ptr, "relative_path", BLI_path_is_rel(sima->image->name));
image_filesel(C, op, sima->image->name);