From afb1a64ccb81b7ed792f64151986f40f53af8da5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 26 Mar 2020 17:52:41 +0100 Subject: Fix T60682: adds macOS alias redirection for directories This adds support for macOS aliases in addition to symlinks. It also adds support for hidden, readonly and system file attributes. Contributed by Ankit (ankitm) with modifications by me. Differential Revision: https://developer.blender.org/D6679 --- source/blender/blenlib/intern/storage.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'source/blender/blenlib/intern/storage.c') diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index da80777e6d6..7274a15661a 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -226,11 +226,12 @@ size_t BLI_file_size(const char *path) return stats.st_size; } +#ifndef __APPLE__ eFileAttributes BLI_file_attributes(const char *path) { int ret = 0; -#ifdef WIN32 +# ifdef WIN32 wchar_t wline[FILE_MAXDIR]; BLI_strncpy_wchar_from_utf8(wline, path, ARRAY_SIZE(wline)); DWORD attr = GetFileAttributesW(wline); @@ -265,19 +266,9 @@ eFileAttributes BLI_file_attributes(const char *path) ret |= FILE_ATTR_REPARSE_POINT; } -#endif - -#ifdef __APPLE__ - - /* TODO: - * If Hidden (Invisible) set FILE_ATTR_HIDDEN - * If Locked set FILE_ATTR_READONLY - * If Restricted set FILE_ATTR_RESTRICTED - */ - -#endif +# endif -#ifdef __linux__ +# ifdef __linux__ UNUSED_VARS(path); /* TODO: @@ -285,10 +276,23 @@ eFileAttributes BLI_file_attributes(const char *path) * If Archived set FILE_ATTR_ARCHIVE */ -#endif +# endif return ret; } +#endif + +/** + * Returns the target path of a file-based redirection, like Mac Alias or Win32 Shortcut file. + */ +#ifndef __APPLE__ +bool BLI_file_alias_target(char UNUSED(target[FILE_MAXDIR]), const char *UNUSED(filepath)) +{ + /* TODO: Find target in Win32 Shortcut - Shell Link (.lnk) file. + * Format: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-shllink/ */ + return false; +} +#endif /** * Returns the st_mode from stat-ing the specified path name, or 0 if stat fails -- cgit v1.2.3