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/editors/space_file/file_utils.c')
-rw-r--r--source/blender/editors/space_file/file_utils.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/editors/space_file/file_utils.c b/source/blender/editors/space_file/file_utils.c
index 452f2f704cf..9d85996c559 100644
--- a/source/blender/editors/space_file/file_utils.c
+++ b/source/blender/editors/space_file/file_utils.c
@@ -18,12 +18,14 @@
* \ingroup spfile
*/
+#include "BLI_fileops.h"
#include "BLI_listbase.h"
+#include "BLI_path_util.h"
#include "BLI_rect.h"
-
-#include "BLO_readfile.h"
+#include "BLI_string.h"
#include "BKE_context.h"
+#include "BLO_readfile.h"
#include "ED_fileselect.h"
#include "ED_screen.h"
@@ -44,3 +46,14 @@ void file_tile_boundbox(const ARegion *region, FileLayout *layout, const int fil
ymax - layout->tile_h - layout->tile_border_y,
ymax);
}
+
+/**
+ * If \a path leads to a .blend, remove the trailing slash (if needed).
+ */
+void file_path_to_ui_path(const char *path, char *r_path, int max_size)
+{
+ char tmp_path[PATH_MAX];
+ BLI_strncpy(tmp_path, path, sizeof(tmp_path));
+ BLI_path_slash_rstrip(tmp_path);
+ BLI_strncpy(r_path, BLO_has_bfile_extension(tmp_path) ? tmp_path : path, max_size);
+}