2 * Copyright (C) 2009-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #if defined(TARGET_DARWIN_OSX)
10 #include "utils/URIUtils.h"
11 #include "platform/darwin/DarwinUtils.h"
12 #elif defined(TARGET_POSIX)
16 #include "AliasShortcutUtils.h"
17 #include "utils/log.h"
19 bool IsAliasShortcut(const std::string
& path
, bool isdirectory
)
23 #if defined(TARGET_DARWIN_OSX)
24 // Note: regular files that have an .alias extension can be
25 // reported as an alias when clearly, they are not. Trap them out.
26 if (!URIUtils::HasExtension(path
, ".alias"))//! @todo - check if this is still needed with the new API
28 rtn
= CDarwinUtils::IsAliasShortcut(path
, isdirectory
);
30 #elif defined(TARGET_POSIX)
31 // Linux does not use alias or shortcut methods
32 #elif defined(TARGET_WINDOWS)
33 /* Needs testing under Windows platform so ignore shortcuts for now
34 if (CUtil::GetExtension(path) == ".lnk")
43 void TranslateAliasShortcut(std::string
& path
)
45 #if defined(TARGET_DARWIN_OSX)
46 CDarwinUtils::TranslateAliasShortcut(path
);
47 #elif defined(TARGET_POSIX)
48 // Linux does not use alias or shortcut methods
49 #elif defined(TARGET_WINDOWS_STORE)
50 // Win10 does not use alias or shortcut methods
51 CLog::Log(LOGDEBUG
, "{} is not implemented", __FUNCTION__
);
52 #elif defined(TARGET_WINDOWS)
53 /* Needs testing under Windows platform so ignore shortcuts for now
54 CComPtr<IShellLink> ipShellLink;
56 // Get a pointer to the IShellLink interface
57 if (NOERROR == CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&ipShellLink))
58 WCHAR wszTemp[MAX_PATH];
60 // Get a pointer to the IPersistFile interface
61 CComQIPtr<IPersistFile> ipPersistFile(ipShellLink);
63 // IPersistFile is using LPCOLESTR so make sure that the string is Unicode
65 MultiByteToWideChar(CP_ACP, 0, lpszShortcutPath, -1, wszTemp, MAX_PATH);
67 wcsncpy(wszTemp, lpszShortcutPath, MAX_PATH);
70 // Open the shortcut file and initialize it from its contents
71 if (NOERROR == ipPersistFile->Load(wszTemp, STGM_READ))
73 // Try to find the target of a shortcut even if it has been moved or renamed
74 if (NOERROR == ipShellLink->Resolve(NULL, SLR_UPDATE))
77 TCHAR real_path[PATH_MAX];
78 // Get the path to the shortcut target
79 if (NOERROR == ipShellLink->GetPath(real_path, MAX_PATH, &wfd, SLGP_RAWPATH))
81 // Get the description of the target
82 TCHAR szDesc[MAX_PATH];
83 if (NOERROR == ipShellLink->GetDescription(szDesc, MAX_PATH))