forked from enlightenment/efl
Evil: remove "symlink" code (it was for .lnk files anyway...)
This commit is contained in:
parent
8f5029fbbc
commit
1770059b8a
|
@ -35,7 +35,6 @@ lib/evil/evil_fnmatch.c \
|
|||
lib/evil/evil_fnmatch_list_of_states.c \
|
||||
lib/evil/evil_langinfo.c \
|
||||
lib/evil/evil_locale.c \
|
||||
lib/evil/evil_link_xp.cpp \
|
||||
lib/evil/evil_main.c \
|
||||
lib/evil/evil_mman.c \
|
||||
lib/evil/evil_pwd.c \
|
||||
|
@ -50,7 +49,6 @@ lib/evil/evil_fnmatch_private.h
|
|||
|
||||
lib_evil_libevil_la_CPPFLAGS = @EVIL_CPPFLAGS@
|
||||
lib_evil_libevil_la_CFLAGS = @EVIL_CFLAGS@ @EVIL_CFLAGS_WRN@ -D__USE_MINGW_ANSI_STDIO
|
||||
lib_evil_libevil_la_CXXFLAGS = @EVIL_CXXFLAGS@ @EVIL_CFLAGS@
|
||||
lib_evil_libevil_la_LIBADD = @EVIL_LIBS@
|
||||
lib_evil_libevil_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
|
||||
|
||||
|
|
|
@ -1,149 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <shlobj.h>
|
||||
#include <objidl.h>
|
||||
#include <cstdio>
|
||||
|
||||
#include "Evil.h"
|
||||
|
||||
|
||||
/*
|
||||
* Symbolic links and directory related functions
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* REMARK: Windows has no symbolic link. */
|
||||
/* Nevertheless, it can create and read .lnk files */
|
||||
int
|
||||
symlink(const char *oldpath, const char *newpath)
|
||||
{
|
||||
char fullname[PATH_MAX];
|
||||
wchar_t *wnewpath;
|
||||
IShellLink *pISL;
|
||||
IPersistFile *pIPF;
|
||||
HRESULT res;
|
||||
size_t size;
|
||||
|
||||
realpath(oldpath, fullname);
|
||||
|
||||
res = CoInitialize(NULL);
|
||||
if (FAILED(res))
|
||||
{
|
||||
if (res == E_OUTOFMEMORY)
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (FAILED(CoCreateInstance(CLSID_ShellLink,
|
||||
NULL,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_IShellLink,
|
||||
(void **)&pISL)))
|
||||
goto no_instance;
|
||||
|
||||
if (FAILED(pISL->SetPath(fullname)))
|
||||
goto no_setpath;
|
||||
|
||||
if (FAILED(pISL->QueryInterface(IID_IPersistFile, (void **)&pIPF)))
|
||||
goto no_queryinterface;
|
||||
|
||||
size = mbstowcs(NULL, newpath, 0);
|
||||
wnewpath = (wchar_t *)malloc((size + 1) * sizeof(wchar_t));
|
||||
if (!wnewpath)
|
||||
goto malloc_failure;
|
||||
if (mbstowcs(wnewpath, newpath, size + 1) == (size_t)(-1))
|
||||
goto translation_failure;
|
||||
if (FAILED(pIPF->Save(wnewpath, FALSE)))
|
||||
goto no_save;
|
||||
|
||||
free(wnewpath);
|
||||
pIPF->Release();
|
||||
pISL->Release();
|
||||
CoUninitialize();
|
||||
|
||||
return 0;
|
||||
|
||||
no_save:
|
||||
translation_failure:
|
||||
malloc_failure:
|
||||
pIPF->Release();
|
||||
no_queryinterface:
|
||||
no_setpath:
|
||||
pISL->Release();
|
||||
no_instance:
|
||||
CoUninitialize();
|
||||
return -1;
|
||||
}
|
||||
|
||||
ssize_t
|
||||
readlink(const char *path, char *buf, size_t bufsiz)
|
||||
{
|
||||
wchar_t *wpath;
|
||||
char new_path[PATH_MAX];
|
||||
IShellLink *pISL;
|
||||
IPersistFile *pIPF;
|
||||
size_t length;
|
||||
HRESULT res;
|
||||
size_t size;
|
||||
|
||||
res = CoInitialize(NULL);
|
||||
if (FAILED(res))
|
||||
{
|
||||
if (res == E_OUTOFMEMORY)
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (FAILED(CoCreateInstance(CLSID_ShellLink,
|
||||
NULL,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_IShellLink,
|
||||
(void **)&pISL)))
|
||||
goto couninitialize;
|
||||
|
||||
if (FAILED(pISL->QueryInterface(IID_IPersistFile, (void **)&pIPF)))
|
||||
goto release_shell_link;
|
||||
|
||||
size = mbstowcs(NULL, path, 0);
|
||||
wpath = (wchar_t *)malloc((size + 1) * sizeof(wchar_t));
|
||||
if (!wpath)
|
||||
goto release_persist_file;
|
||||
|
||||
mbstowcs(wpath, path, size + 1);
|
||||
if (FAILED(pIPF->Load(wpath, STGM_READ)))
|
||||
goto free_wpath;
|
||||
|
||||
if (FAILED(pISL->Resolve(NULL, SLR_UPDATE | SLR_NO_UI)))
|
||||
goto free_wpath;
|
||||
|
||||
if (FAILED(pISL->GetPath(new_path, PATH_MAX, NULL, 0)))
|
||||
goto free_wpath;
|
||||
|
||||
length = strlen(new_path);
|
||||
if (length > bufsiz)
|
||||
length = bufsiz;
|
||||
|
||||
memcpy(buf, new_path, length);
|
||||
|
||||
free(wpath);
|
||||
pISL->Release();
|
||||
pIPF->Release();
|
||||
CoUninitialize();
|
||||
|
||||
return length;
|
||||
|
||||
free_wpath:
|
||||
free(wpath);
|
||||
release_persist_file:
|
||||
pIPF->Release();
|
||||
release_shell_link:
|
||||
pISL->Release();
|
||||
couninitialize:
|
||||
CoUninitialize();
|
||||
return -1;
|
||||
}
|
|
@ -37,62 +37,6 @@
|
|||
EAPI double evil_time_get(void);
|
||||
|
||||
|
||||
/*
|
||||
* Symbolic links and directory related functions
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Create a shell link.
|
||||
*
|
||||
* @param oldpath The file name to be linked.
|
||||
* @param newpath The file name to create.
|
||||
* @return 0 on success, -1 otherwise.
|
||||
*
|
||||
* Create a shell link @p newpath to @p oldpath (@p newpath is the
|
||||
* name of the file created, @p oldpath is the string used in
|
||||
* creating the shell link).
|
||||
*
|
||||
* On success, this function returns 0. Otherwise, it returns -1 and
|
||||
* errno may be set to the following value:
|
||||
* - ENOMEM: Not enough memory.
|
||||
*
|
||||
* On Windows, the symbolic links do not exist. Nevertheless
|
||||
* shell links can be created. This function is named like the Unix
|
||||
* function for portability reasons.
|
||||
*
|
||||
* Conformity: None.
|
||||
*
|
||||
* Supported OS: Windows XP.
|
||||
*/
|
||||
EAPI int symlink(const char *oldpath, const char *newpath);
|
||||
|
||||
/**
|
||||
* @brief Read value of a shell link.
|
||||
*
|
||||
* @param path The file name to be linked.
|
||||
* @param buf The file name to create.
|
||||
* @param bufsiz The size of the buffer.
|
||||
* @return 0 on success, -1 otherwise.
|
||||
*
|
||||
* Place the content of the shell link @p path in the buffer
|
||||
* @p buf, which has size @p bufzsiz.
|
||||
*
|
||||
* On success, this function returns 0. Otherwise, it returns -1 and
|
||||
* errno may be set to the following value:
|
||||
* - ENOMEM: Not enough memory.
|
||||
*
|
||||
* On Windows, the symbolic links do not exist. Nevertheless
|
||||
* shell links can be managed. This function is named like the Unix
|
||||
* function for portability reasons.
|
||||
*
|
||||
* Conformity: None.
|
||||
*
|
||||
* Supported OS: Windows XP.
|
||||
*/
|
||||
EAPI ssize_t readlink(const char *path, char *buf, size_t bufsiz);
|
||||
|
||||
|
||||
/*
|
||||
* file related functions
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue