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/blenlib/intern/storage.c
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/blenlib/intern/storage.c')
-rw-r--r--source/blender/blenlib/intern/storage.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index 20830570432..2c6fc9f2058 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -478,16 +478,29 @@ int BLI_exists(const char *name)
#else
struct _stati64 st;
#endif
- /* in Windows stat doesn't recognize dir ending on a slash
- * To not break code where the ending slash is expected we
- * don't mess with the argument name directly here - elubie */
- wchar_t *tmp_16 = alloc_utf16_from_8(name, 0);
+ wchar_t *tmp_16 = alloc_utf16_from_8(name, 1);
int len, res;
unsigned int old_error_mode;
len = wcslen(tmp_16);
- if (len > 3 && (tmp_16[len - 1] == L'\\' || tmp_16[len - 1] == L'/'))
+ /* in Windows #stat doesn't recognize dir ending on a slash
+ * so we remove it here */
+ if (len > 3 && (tmp_16[len - 1] == L'\\' || tmp_16[len - 1] == L'/')) {
tmp_16[len - 1] = '\0';
+ }
+ /* two special cases where the trailing slash is needed:
+ * 1. after the share part of a UNC path
+ * 2. after the C:\ when the path is the volume only
+ */
+ if ((len >= 3) && (tmp_16[0] == L'\\') && (tmp_16[1] == L'\\')) {
+ BLI_cleanup_unc_16(tmp_16);
+ }
+
+ if ((tmp_16[1] == L':') && (tmp_16[2] == L'\0')) {
+ tmp_16[2] = L'\\';
+ tmp_16[3] = L'\0';
+ }
+
/* change error mode so user does not get a "no disk in drive" popup
* when looking for a file on an empty CD/DVD drive */