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:
authorAndrea Weikert <elubie@gmx.net>2014-04-21 18:49:35 +0400
committerAndrea Weikert <elubie@gmx.net>2014-04-21 19:06:09 +0400
commit5afb0abfbd7b93d6b42c594146b53f3ab5d6b9d0 (patch)
tree8b4e35fdca9d0fea480c7b9a2b9ef49367d01f74 /source/blender/editors/space_file
parent87628cc5fb068cb6b5cd3a3aee3bc4e405bdaf24 (diff)
Basic support for UNC paths on Windows
Differential Revision: https://developer.blender.org/D298 Allows users on Windows to enter UNC paths in the filebrowser and to link to .blend files on a UNC path. Functionality is limited still, we can't browse the network yet and have no support to check user rights so far. What works: - enter an UNC path in the file browser manually or via copy/paste - navigation within the UNC share subfolders - link to a file on a UNC share What does not (yet) work: - browse the network for computers and shares - browse to a folder that requires entering user credentials Contributors: Rob McKay - original patch Campbell Barton - style fixes Reviewers: Campbell Barton, Brecht van Lommel
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r--source/blender/editors/space_file/file_ops.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 9c8bcc09a3e..031dcddd89a 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -857,7 +857,19 @@ int file_parent_exec(bContext *C, wmOperator *UNUSED(unused))
if (sfile->params) {
if (BLI_parent_dir(sfile->params->dir)) {
BLI_cleanup_dir(G.main->name, sfile->params->dir);
- file_change_dir(C, 0);
+ /* if not browsing in .blend file, we still want to check whether the path is a directory */
+ if (sfile->params->type == FILE_LOADLIB) {
+ char tdir[FILE_MAX], tgroup[FILE_MAX];
+ if (BLO_is_a_library(sfile->params->dir, tdir, tgroup)) {
+ file_change_dir(C, 0);
+ }
+ else {
+ file_change_dir(C, 1);
+ }
+ }
+ else {
+ file_change_dir(C, 1);
+ }
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
}
}
@@ -1206,10 +1218,30 @@ static void file_expand_directory(bContext *C)
sfile->params->dir[2] = '\\';
sfile->params->dir[3] = '\0';
}
+ else if (BLI_path_is_unc(sfile->params->dir)) {
+ BLI_cleanup_unc(sfile->params->dir, FILE_MAX_LIBEXTRA);
+ }
#endif
}
}
+#if defined(WIN32)
+static bool can_create_dir(const char *dir)
+{
+ /* for UNC paths we need to check whether the parent of the new
+ * directory is a proper directory itself and not a share or the
+ * UNC root (server name) itself. Calling BLI_is_dir does this
+ */
+ if (BLI_path_is_unc(dir)) {
+ char parent[PATH_MAX];
+ BLI_strncpy(parent, dir, PATH_MAX);
+ BLI_parent_dir(parent);
+ return BLI_is_dir(parent);
+ }
+ return true;
+}
+#endif
+
void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UNUSED(arg_but))
{
SpaceFile *sfile = CTX_wm_space_file(C);
@@ -1234,6 +1266,13 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN
* placing cursor at the end */
/* UI_textbutton_activate_but(C, but); */
}
+#if defined(WIN32)
+ else if (!can_create_dir(sfile->params->dir)) {
+ const char *lastdir = folderlist_peeklastdir(sfile->folders_prev);
+ if (lastdir)
+ BLI_strncpy(sfile->params->dir, lastdir, sizeof(sfile->params->dir));
+ }
+#endif
else {
const char *lastdir = folderlist_peeklastdir(sfile->folders_prev);