summaryrefslogtreecommitdiffstats
path: root/xbmc/utils/AliasShortcutUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/utils/AliasShortcutUtils.cpp')
-rw-r--r--xbmc/utils/AliasShortcutUtils.cpp93
1 files changed, 93 insertions, 0 deletions
diff --git a/xbmc/utils/AliasShortcutUtils.cpp b/xbmc/utils/AliasShortcutUtils.cpp
new file mode 100644
index 0000000..001bc43
--- /dev/null
+++ b/xbmc/utils/AliasShortcutUtils.cpp
@@ -0,0 +1,93 @@
1/*
2 * Copyright (C) 2009-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#if defined(TARGET_DARWIN_OSX)
10#include "utils/URIUtils.h"
11#include "platform/darwin/DarwinUtils.h"
12#elif defined(TARGET_POSIX)
13#else
14#endif
15
16#include "AliasShortcutUtils.h"
17#include "utils/log.h"
18
19bool IsAliasShortcut(const std::string& path, bool isdirectory)
20{
21 bool rtn = false;
22
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
27 {
28 rtn = CDarwinUtils::IsAliasShortcut(path, isdirectory);
29 }
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")
35 {
36 rtn = true;
37 }
38*/
39#endif
40 return(rtn);
41}
42
43void TranslateAliasShortcut(std::string& path)
44{
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, "%s is not implemented", __FUNCTION__);
52#elif defined(TARGET_WINDOWS)
53/* Needs testing under Windows platform so ignore shortcuts for now
54 CComPtr<IShellLink> ipShellLink;
55
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];
59
60 // Get a pointer to the IPersistFile interface
61 CComQIPtr<IPersistFile> ipPersistFile(ipShellLink);
62
63 // IPersistFile is using LPCOLESTR so make sure that the string is Unicode
64#if !defined _UNICODE
65 MultiByteToWideChar(CP_ACP, 0, lpszShortcutPath, -1, wszTemp, MAX_PATH);
66#else
67 wcsncpy(wszTemp, lpszShortcutPath, MAX_PATH);
68#endif
69
70 // Open the shortcut file and initialize it from its contents
71 if (NOERROR == ipPersistFile->Load(wszTemp, STGM_READ))
72 {
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))
75 {
76 WIN32_FIND_DATA wfd;
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))
80 {
81 // Get the description of the target
82 TCHAR szDesc[MAX_PATH];
83 if (NOERROR == ipShellLink->GetDescription(szDesc, MAX_PATH))
84 {
85 path = real_path;
86 }
87 }
88 }
89 }
90 }
91*/
92#endif
93}