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:
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenlib/BLI_path_util.h11
-rw-r--r--source/blender/blenlib/intern/path_util.c70
-rw-r--r--source/blender/render/intern/render_result.cc16
-rw-r--r--source/blender/windowmanager/intern/wm_files.c3
4 files changed, 13 insertions, 87 deletions
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index a2caaa0851b..75002f52d94 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -36,17 +36,6 @@ void BLI_setenv_if_new(const char *env, const char *val) ATTR_NONNULL(1);
const char *BLI_getenv(const char *env) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
/**
- * Returns in `string` the concatenation of `dir` and `file` (also with `relabase` on the
- * front if specified and `dir` begins with "//"). Normalizes all occurrences of path
- * separators, including ensuring there is exactly one between the copies of `dir` and `file`,
- * and between the copies of `relabase` and `dir`.
- *
- * \param relabase: Optional prefix to substitute for "//" on front of `dir`.
- * \param string: Area to return result.
- */
-void BLI_make_file_string(const char *relabase, char *string, const char *dir, const char *file)
- ATTR_NONNULL(2, 3, 4);
-/**
* Ensures that the parent directory of `name` exists.
*
* \return true on success (i.e. given path now exists on file-system), false otherwise.
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 73396fb34b1..1e95aa3b7b0 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -1204,76 +1204,6 @@ bool BLI_make_existing_file(const char *name)
return BLI_dir_create_recursive(di);
}
-void BLI_make_file_string(const char *relabase, char *string, const char *dir, const char *file)
-{
- /* Ensure this is always set & the following `strcat` works as expected. */
- string[0] = '\0';
-
- /* Resolve relative references */
- if (relabase && dir[0] == '/' && dir[1] == '/') {
- char *lslash;
-
- /* Get the file name, chop everything past the last slash (ie. the filename) */
- strcpy(string, relabase);
-
- lslash = (char *)BLI_path_slash_rfind(string);
- if (lslash) {
- *(lslash + 1) = 0;
- }
-
- dir += 2; /* Skip over the relative reference */
- }
-#ifdef WIN32
- else {
- if (BLI_strnlen(dir, 3) >= 2 && dir[1] == ':') {
- BLI_strncpy(string, dir, 3);
- dir += 2;
- }
- else if (BLI_strnlen(dir, 3) >= 2 && BLI_path_is_unc(dir)) {
- string[0] = 0;
- }
- else { /* no drive specified */
- /* first option: get the drive from the relabase if it has one */
- if (relabase && BLI_strnlen(relabase, 3) >= 2 && relabase[1] == ':') {
- BLI_strncpy(string, relabase, 3);
- string[2] = '\\';
- string[3] = '\0';
- }
- else { /* we're out of luck here, guessing the first valid drive, usually c:\ */
- BLI_windows_get_default_root_dir(string);
- }
-
- /* ignore leading slashes */
- while (ELEM(*dir, '/', '\\')) {
- dir++;
- }
- }
- }
-#endif
-
- strcat(string, dir);
-
- /* Make sure string ends in one (and only one) slash */
- /* first trim all slashes from the end of the string */
- int sl = strlen(string);
- while ((sl > 0) && ELEM(string[sl - 1], '/', '\\')) {
- string[sl - 1] = '\0';
- sl--;
- }
- /* since we've now removed all slashes, put back one slash at the end. */
- strcat(string, "/");
-
- while (ELEM(*file, '/', '\\')) {
- /* Trim slashes from the front of file */
- file++;
- }
-
- strcat(string, file);
-
- /* Push all slashes to the system preferred direction */
- BLI_path_slash_native(string);
-}
-
static bool path_extension_check_ex(const char *str,
const size_t str_len,
const char *ext,
diff --git a/source/blender/render/intern/render_result.cc b/source/blender/render/intern/render_result.cc
index 86ee9ad779a..50eb7e9f2d2 100644
--- a/source/blender/render/intern/render_result.cc
+++ b/source/blender/render/intern/render_result.cc
@@ -929,7 +929,11 @@ int render_result_exr_file_read_path(RenderResult *rr,
return 1;
}
-static void render_result_exr_file_cache_path(Scene *sce, const char *root, char *r_path)
+#define FILE_CACHE_MAX (FILE_MAXFILE + FILE_MAXFILE + MAX_ID_NAME + 100)
+
+static void render_result_exr_file_cache_path(Scene *sce,
+ const char *root,
+ char r_path[FILE_CACHE_MAX])
{
char filename_full[FILE_MAX + MAX_ID_NAME + 100], filename[FILE_MAXFILE], dirname[FILE_MAXDIR];
char path_digest[16] = {0};
@@ -959,13 +963,17 @@ static void render_result_exr_file_cache_path(Scene *sce, const char *root, char
filename,
sce->id.name + 2,
path_hexdigest);
- BLI_make_file_string(dirname, r_path, root, filename_full);
+
+ BLI_join_dirfile(r_path, FILE_CACHE_MAX, root, filename_full);
+ if (BLI_path_is_rel(r_path)) {
+ BLI_path_abs(r_path, dirname);
+ }
}
void render_result_exr_file_cache_write(Render *re)
{
RenderResult *rr = re->result;
- char str[FILE_MAXFILE + FILE_MAXFILE + MAX_ID_NAME + 100];
+ char str[FILE_CACHE_MAX];
char *root = U.render_cachedir;
render_result_passes_allocated_ensure(rr);
@@ -979,7 +987,7 @@ void render_result_exr_file_cache_write(Render *re)
bool render_result_exr_file_cache_read(Render *re)
{
/* File path to cache. */
- char filepath[FILE_MAXFILE + MAX_ID_NAME + MAX_ID_NAME + 100] = "";
+ char filepath[FILE_CACHE_MAX] = "";
char *root = U.render_cachedir;
render_result_exr_file_cache_path(re->scene, root, filepath);
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 38747bd706c..186edfe68d6 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -1923,8 +1923,7 @@ static void wm_autosave_location(char filepath[FILE_MAX])
/* XXX Need to investigate how to handle default location of `/tmp/`
* This is a relative directory on Windows, and it may be found. Example:
* Blender installed on `D:\` drive, `D:\` drive has `D:\tmp\` Now, `BLI_exists()`
- * will find `/tmp/` exists, but #BLI_make_file_string will create string
- * that has it most likely on `C:\` through #BLI_windows_get_default_root_dir.
+ * will find `/tmp/` exists, but #BLI_windows_get_default_root_dir will expand this to `C:\`.
* If there is no `C:\tmp` autosave fails. */
if (!BLI_exists(tempdir_base)) {
const char *savedir = BKE_appdir_folder_id_create(BLENDER_USER_AUTOSAVE, NULL);