efl/src/lib/evil/evil_link_ce.c

91 lines
1.6 KiB
C
Raw Normal View History

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
* AUTHORS: * src/lib/Evil.h: * src/lib/Makefile.am: * src/lib/evil_inet.c: * src/lib/evil_mman.c: * src/lib/evil_stdio.c: * src/lib/evil_stdio.h: * src/lib/evil_stdlib.c: * src/lib/evil_util.c: * src/lib/sys/mman.h: * src/lib/evil_printa.c (added): * src/lib/evil_pformatw.c (added): * src/lib/evil_pformat.h (added): * src/lib/evil_printw.c (added): * src/lib/evil_print.h (added): * src/lib/evil_macro.h (added): * src/lib/evil_pformata.c (added): Add POSIX printf family. Code taken from the MinGW-w64 project and modified to be integrated into Evil. * src/bin/Makefile.am: * src/bin/evil_suite.c: * src/bin/evil_test_util.h (added): * src/bin/evil_test_print.c (added): * src/bin/evil_test_print.h (added): * src/bin/evil_test_util.c (added): Add util and printf unit tests * src/lib/evil_errno.c: * src/lib/errno.h (deleted): * src/lib/mingw32ce (added): * src/lib/mingw32ce/errno.h (added): Move errno.h for Windows CE in its own directory to suppress conflicts with standard errno.h when compiling for Windows XP. * src/lib/dlfcn/dlfcn.c: * src/lib/evil_link_ce.c: * src/lib/evil_main.c: * src/lib/evil_unistd.c: Define WIN32_LEAN_AND_MEAN only if it's not defined. * src/lib/evil_fcntl.c: Remove debug. * src/bin/evil_test_dlfcn.c: * src/bin/evil_test_environment.c: * src/bin/evil_test_gettimeofday.c: * src/bin/evil_test_link.c: * src/bin/evil_test_mkstemp.c: * src/bin/evil_test_pipe.c: * src/bin/evil_test_realpath.c: Remove warnings. * src/lib/evil_link_xp.cpp: Formatting. SVN revision: 68084
2012-02-17 12:48:11 -08:00
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#include <shellapi.h>
#include "Evil.h"
#include "evil_private.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)
{
wchar_t *w_oldpath;
wchar_t *w_newpath;
BOOL res;
w_oldpath = evil_char_to_wchar(oldpath);
if (!w_oldpath)
return -1;
w_newpath = evil_char_to_wchar(newpath);
if (!w_newpath)
{
free(w_oldpath);
return -1;
}
res = SHCreateShortcut(w_newpath, w_oldpath);
if (!res)
_evil_last_error_display(__FUNCTION__);
free(w_oldpath);
free(w_newpath);
return res ? 0 : -1;
}
ssize_t
readlink(const char *path, char *buf, size_t bufsiz)
{
wchar_t *w_path;
wchar_t w_newpath[1024];
char *newpath;
size_t length;
BOOL res;
w_path = evil_char_to_wchar(path);
if (!w_path)
return -1;
res = SHGetShortcutTarget(w_path, w_newpath, 1024);
if (!res)
_evil_last_error_display(__FUNCTION__);
free(w_path);
if (!res)
return -1;
newpath = evil_wchar_to_char(w_newpath);
if (!newpath)
return -1;
/* That stupid SHGetShortcutTarget add " around the file name... */
length = strlen(newpath) - 2;
if (length > bufsiz)
length = bufsiz;
memcpy(buf, newpath + 1, length);
free(newpath);
return length;
}