Home » U++ Library support » U++ Core » Symlink/Shortcut support
Symlink/Shortcut support [message #24830] |
Mon, 01 February 2010 08:02  |
 |
koldo
Messages: 3432 Registered: August 2008
|
Senior Veteran |
|
|
Hello all
Now symlinks-shortcuts are supported in Core only in Linux with:
It would be good to have a wider support in Linux and Windows.
The proposal is to add IsSymlink() for both OS and a new function like bool GetSymLinkPath(const char *linkPath, String &filePath); to get the real path of the symlink.
The implementation could be (some parts has been borrowed from U++):
bool IsSymLink(const char *path) {
#ifdef PLATFORM_WIN32
return GetFileExt(path) == ".lnk";
#else
struct stat stf;
lstat(path, &stf);
return S_ISLNK(stf.st_mode);
#endif
}
bool GetSymLinkPath(const char *linkPath, String &filePath)
{
#ifdef PLATFORM_WIN32
HRESULT hres;
IShellLink* psl;
IPersistFile* ppf;
CoInitialize(NULL);
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink,
(PVOID *) &psl);
if(SUCCEEDED(hres)) {
hres = psl->QueryInterface(IID_IPersistFile, (PVOID *) &ppf);
if(SUCCEEDED(hres)) {
hres = ppf->Load(ToSystemCharsetW(linkPath), STGM_READ);
if(SUCCEEDED(hres)) {
char fileW[_MAX_PATH] = {0};
psl->GetPath(fileW, _MAX_PATH, NULL, 0);
filePath = FromSystemCharset(fileW);
} else
return false;
ppf->Release();
} else
return false;
psl->Release();
} else
return false;
CoUninitialize();
return true;
#else
char buff[_MAX_PATH + 1];
bool ret;
int len = readlink(linkPath, buff, _MAX_PATH);
if (ret = (len > 0 && len < _MAX_PATH))
buff[len] = '\0';
else
*buff = '\0';
filePath = buff;
return ret;
#endif
}
Best regards
IƱaki
|
|
|
 |
|
Symlink/Shortcut support
By: koldo on Mon, 01 February 2010 08:02
|
 |
|
Re: Symlink/Shortcut support
By: mirek on Mon, 01 February 2010 14:42
|
 |
|
Re: Symlink/Shortcut support
By: koldo on Mon, 01 February 2010 15:49
|
 |
|
Re: Symlink/Shortcut support
|
 |
|
Re: Symlink/Shortcut support
By: koldo on Mon, 01 February 2010 16:24
|
 |
|
Re: Symlink/Shortcut support
By: fudadmin on Mon, 01 February 2010 21:40
|
 |
|
Re: Symlink/Shortcut support
By: mirek on Mon, 01 February 2010 22:29
|
 |
|
Re: Symlink/Shortcut support
By: mirek on Fri, 05 February 2010 10:22
|
 |
|
Re: Symlink/Shortcut support
By: mirek on Fri, 05 February 2010 10:25
|
 |
|
Re: Symlink/Shortcut support
By: koldo on Fri, 05 February 2010 11:42
|
 |
|
Re: Symlink/Shortcut support
By: mirek on Sat, 06 February 2010 12:49
|
 |
|
Re: Symlink/Shortcut support
By: mirek on Sat, 06 February 2010 13:20
|
 |
|
Re: Symlink/Shortcut support
By: koldo on Sat, 06 February 2010 14:30
|
 |
|
Re: Symlink/Shortcut support
By: mirek on Sat, 06 February 2010 19:40
|
 |
|
Re: Symlink/Shortcut support
By: koldo on Sat, 06 February 2010 23:13
|
 |
|
Re: Symlink/Shortcut support
By: mirek on Sat, 06 February 2010 23:19
|
 |
|
Re: Symlink/Shortcut support
By: mirek on Sat, 06 February 2010 23:26
|
Goto Forum:
Current Time: Fri May 02 14:37:01 CEST 2025
Total time taken to generate the page: 0.01332 seconds
|