summaryrefslogtreecommitdiff
path: root/src/lib/evil
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2018-01-29 14:49:54 +0100
committerJean-Philippe Andre <jp.andre@samsung.com>2018-01-30 16:52:24 +0900
commit1770059b8ad4d3584e1c4661e5c562f33dacfffc (patch)
treef9ee6a0bf5ecd2234ce8255073f80d434b69efaa /src/lib/evil
parent8f5029fbbc5bf776938ffea7d8115cd1c574e308 (diff)
Evil: remove "symlink" code (it was for .lnk files anyway...)
Diffstat (limited to 'src/lib/evil')
-rw-r--r--src/lib/evil/evil_link_xp.cpp149
-rw-r--r--src/lib/evil/evil_unistd.h56
2 files changed, 0 insertions, 205 deletions
diff --git a/src/lib/evil/evil_link_xp.cpp b/src/lib/evil/evil_link_xp.cpp
deleted file mode 100644
index 2b5b956..0000000
--- a/src/lib/evil/evil_link_xp.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif /* HAVE_CONFIG_H */
4
5#include <errno.h>
6
7#include <shlobj.h>
8#include <objidl.h>
9#include <cstdio>
10
11#include "Evil.h"
12
13
14/*
15 * Symbolic links and directory related functions
16 *
17 */
18
19
20/* REMARK: Windows has no symbolic link. */
21/* Nevertheless, it can create and read .lnk files */
22int
23symlink(const char *oldpath, const char *newpath)
24{
25 char fullname[PATH_MAX];
26 wchar_t *wnewpath;
27 IShellLink *pISL;
28 IPersistFile *pIPF;
29 HRESULT res;
30 size_t size;
31
32 realpath(oldpath, fullname);
33
34 res = CoInitialize(NULL);
35 if (FAILED(res))
36 {
37 if (res == E_OUTOFMEMORY)
38 errno = ENOMEM;
39 return -1;
40 }
41
42 if (FAILED(CoCreateInstance(CLSID_ShellLink,
43 NULL,
44 CLSCTX_INPROC_SERVER,
45 IID_IShellLink,
46 (void **)&pISL)))
47 goto no_instance;
48
49 if (FAILED(pISL->SetPath(fullname)))
50 goto no_setpath;
51
52 if (FAILED(pISL->QueryInterface(IID_IPersistFile, (void **)&pIPF)))
53 goto no_queryinterface;
54
55 size = mbstowcs(NULL, newpath, 0);
56 wnewpath = (wchar_t *)malloc((size + 1) * sizeof(wchar_t));
57 if (!wnewpath)
58 goto malloc_failure;
59 if (mbstowcs(wnewpath, newpath, size + 1) == (size_t)(-1))
60 goto translation_failure;
61 if (FAILED(pIPF->Save(wnewpath, FALSE)))
62 goto no_save;
63
64 free(wnewpath);
65 pIPF->Release();
66 pISL->Release();
67 CoUninitialize();
68
69 return 0;
70
71 no_save:
72 translation_failure:
73 malloc_failure:
74 pIPF->Release();
75 no_queryinterface:
76 no_setpath:
77 pISL->Release();
78 no_instance:
79 CoUninitialize();
80 return -1;
81}
82
83ssize_t
84readlink(const char *path, char *buf, size_t bufsiz)
85{
86 wchar_t *wpath;
87 char new_path[PATH_MAX];
88 IShellLink *pISL;
89 IPersistFile *pIPF;
90 size_t length;
91 HRESULT res;
92 size_t size;
93
94 res = CoInitialize(NULL);
95 if (FAILED(res))
96 {
97 if (res == E_OUTOFMEMORY)
98 errno = ENOMEM;
99 return -1;
100 }
101
102 if (FAILED(CoCreateInstance(CLSID_ShellLink,
103 NULL,
104 CLSCTX_INPROC_SERVER,
105 IID_IShellLink,
106 (void **)&pISL)))
107 goto couninitialize;
108
109 if (FAILED(pISL->QueryInterface(IID_IPersistFile, (void **)&pIPF)))
110 goto release_shell_link;
111
112 size = mbstowcs(NULL, path, 0);
113 wpath = (wchar_t *)malloc((size + 1) * sizeof(wchar_t));
114 if (!wpath)
115 goto release_persist_file;
116
117 mbstowcs(wpath, path, size + 1);
118 if (FAILED(pIPF->Load(wpath, STGM_READ)))
119 goto free_wpath;
120
121 if (FAILED(pISL->Resolve(NULL, SLR_UPDATE | SLR_NO_UI)))
122 goto free_wpath;
123
124 if (FAILED(pISL->GetPath(new_path, PATH_MAX, NULL, 0)))
125 goto free_wpath;
126
127 length = strlen(new_path);
128 if (length > bufsiz)
129 length = bufsiz;
130
131 memcpy(buf, new_path, length);
132
133 free(wpath);
134 pISL->Release();
135 pIPF->Release();
136 CoUninitialize();
137
138 return length;
139
140 free_wpath:
141 free(wpath);
142 release_persist_file:
143 pIPF->Release();
144 release_shell_link:
145 pISL->Release();
146 couninitialize:
147 CoUninitialize();
148 return -1;
149}
diff --git a/src/lib/evil/evil_unistd.h b/src/lib/evil/evil_unistd.h
index dbc6cfe..5319c47 100644
--- a/src/lib/evil/evil_unistd.h
+++ b/src/lib/evil/evil_unistd.h
@@ -38,62 +38,6 @@ EAPI double evil_time_get(void);
38 38
39 39
40/* 40/*
41 * Symbolic links and directory related functions
42 *
43 */
44
45/**
46 * @brief Create a shell link.
47 *
48 * @param oldpath The file name to be linked.
49 * @param newpath The file name to create.
50 * @return 0 on success, -1 otherwise.
51 *
52 * Create a shell link @p newpath to @p oldpath (@p newpath is the
53 * name of the file created, @p oldpath is the string used in
54 * creating the shell link).
55 *
56 * On success, this function returns 0. Otherwise, it returns -1 and
57 * errno may be set to the following value:
58 * - ENOMEM: Not enough memory.
59 *
60 * On Windows, the symbolic links do not exist. Nevertheless
61 * shell links can be created. This function is named like the Unix
62 * function for portability reasons.
63 *
64 * Conformity: None.
65 *
66 * Supported OS: Windows XP.
67 */
68EAPI int symlink(const char *oldpath, const char *newpath);
69
70/**
71 * @brief Read value of a shell link.
72 *
73 * @param path The file name to be linked.
74 * @param buf The file name to create.
75 * @param bufsiz The size of the buffer.
76 * @return 0 on success, -1 otherwise.
77 *
78 * Place the content of the shell link @p path in the buffer
79 * @p buf, which has size @p bufzsiz.
80 *
81 * On success, this function returns 0. Otherwise, it returns -1 and
82 * errno may be set to the following value:
83 * - ENOMEM: Not enough memory.
84 *
85 * On Windows, the symbolic links do not exist. Nevertheless
86 * shell links can be managed. This function is named like the Unix
87 * function for portability reasons.
88 *
89 * Conformity: None.
90 *
91 * Supported OS: Windows XP.
92 */
93EAPI ssize_t readlink(const char *path, char *buf, size_t bufsiz);
94
95
96/*
97 * file related functions 41 * file related functions
98 * 42 *
99 */ 43 */