summaryrefslogtreecommitdiff
path: root/legacy/ecore/src/lib/ecore_file/ecore_file.c
diff options
context:
space:
mode:
authordoursse <doursse>2008-05-26 05:16:34 +0000
committerdoursse <doursse@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>2008-05-26 05:16:34 +0000
commitcc0ca9325ecd23d25a2d8511c9f5d2af9c275b96 (patch)
tree756d2493d85d4a4191264f1df91af21986533ea2 /legacy/ecore/src/lib/ecore_file/ecore_file.c
parent550d4473201ebef6c450f558bd358d42ad874ace (diff)
integration of evil in ecore. It's compiling on windows and my ubuntu. The commit is big, please report any problem
SVN revision: 34671
Diffstat (limited to '')
-rw-r--r--legacy/ecore/src/lib/ecore_file/ecore_file.c128
1 files changed, 5 insertions, 123 deletions
diff --git a/legacy/ecore/src/lib/ecore_file/ecore_file.c b/legacy/ecore/src/lib/ecore_file/ecore_file.c
index c0298084f8..e99ff63206 100644
--- a/legacy/ecore/src/lib/ecore_file/ecore_file.c
+++ b/legacy/ecore/src/lib/ecore_file/ecore_file.c
@@ -2,7 +2,9 @@
2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3 */ 3 */
4 4
5#include <config.h> 5#ifdef HAVE_CONFIG_H
6# include <config.h>
7#endif
6 8
7#ifndef _FILE_OFFSET_BITS 9#ifndef _FILE_OFFSET_BITS
8# define _FILE_OFFSET_BITS 64 10# define _FILE_OFFSET_BITS 64
@@ -12,132 +14,13 @@
12# include <features.h> 14# include <features.h>
13#endif 15#endif
14#include <ctype.h> 16#include <ctype.h>
15#include "ecore_file_private.h"
16#include <errno.h> 17#include <errno.h>
17 18
18#ifdef _WIN32 19#include "ecore_file_private.h"
19# include <shlobj.h>
20# include <objidl.h>
21#endif /* _WIN32 */
22 20
23 21
24static int init = 0; 22static int init = 0;
25 23
26#ifdef _WIN32
27
28/* FIXME: Windows has no symbolic link. */
29/* Nevertheless, it can create and read .lnk files */
30static int
31symlink(const char *oldpath, const char *newpath)
32{
33 IShellLink *pISL;
34 IShellLink **shell_link;
35 IPersistFile *pIPF;
36 IPersistFile **persit_file;
37 wchar_t new_path[MB_CUR_MAX];
38
39 /* Hack to cleanly remove a warning */
40 if (FAILED(CoInitialize(NULL)))
41 return -1;
42
43 shell_link = &pISL;
44 if (FAILED(CoCreateInstance(&CLSID_ShellLink,
45 NULL,
46 CLSCTX_INPROC_SERVER,
47 &IID_IShellLink,
48 (void **)shell_link)))
49 goto no_instance;
50
51 if (FAILED(pISL->lpVtbl->SetPath(pISL, oldpath)))
52 goto no_setpath;
53
54 /* Hack to cleanly remove a warning */
55 persit_file = &pIPF;
56 if (FAILED(pISL->lpVtbl->QueryInterface(pISL, &IID_IPersistFile, (void **)persit_file)))
57 goto no_queryinterface;
58
59 mbstowcs(new_path, newpath, MB_CUR_MAX);
60 if (FAILED(pIPF->lpVtbl->Save(pIPF, new_path, FALSE)))
61 goto no_save;
62
63 pIPF->lpVtbl->Release(pIPF);
64 pISL->lpVtbl->Release(pISL);
65 CoUninitialize();
66
67 return 0;
68
69 no_save:
70 pIPF->lpVtbl->Release(pIPF);
71 no_queryinterface:
72 no_setpath:
73 pISL->lpVtbl->Release(pISL);
74 no_instance:
75 CoUninitialize();
76 return -1;
77}
78
79static int
80readlink(const char *path, char *buf, size_t bufsiz)
81{
82 IShellLink *pISL;
83 IShellLink **shell_link;
84 IPersistFile *pIPF;
85 IPersistFile **persit_file;
86 wchar_t old_path[MB_CUR_MAX];
87 char new_path[MB_CUR_MAX];
88 int length;
89
90 /* Hack to cleanly remove a warning */
91 if (FAILED(CoInitialize(NULL)))
92 return -1;
93
94 persit_file = &pIPF;
95 if (FAILED(CoCreateInstance(&CLSID_ShellLink,
96 NULL,
97 CLSCTX_INPROC_SERVER,
98 &IID_IPersistFile,
99 (void **)persit_file)))
100 goto no_instance;
101
102 mbstowcs(old_path, path, MB_CUR_MAX);
103 if (FAILED(pIPF->lpVtbl->Load(pIPF, old_path, STGM_READWRITE)))
104 goto no_load;
105
106 shell_link = &pISL;
107 if (FAILED(pIPF->lpVtbl->QueryInterface(pIPF, &IID_IShellLink, (void **)shell_link)))
108 goto no_queryinterface;
109
110 if (FAILED(pISL->lpVtbl->GetPath(pISL, new_path, MB_CUR_MAX, NULL, 0)))
111 goto no_getpath;
112
113 length = strlen(new_path);
114 if (length > bufsiz)
115 length = bufsiz;
116
117 memcpy(buf, new_path, length);
118
119 pISL->lpVtbl->Release(pISL);
120 pIPF->lpVtbl->Release(pIPF);
121 CoUninitialize();
122
123 return length;
124
125 no_getpath:
126 pISL->lpVtbl->Release(pISL);
127 no_queryinterface:
128 no_load:
129 pIPF->lpVtbl->Release(pIPF);
130 no_instance:
131 CoUninitialize();
132 return -1;
133}
134
135#define realpath(file_name, resolved_name) _fullpath((resolved_name), (file_name), PATH_MAX)
136
137#define mkdir(path, mode) _mkdir((path))
138
139#endif /* _WIN32 */
140
141/* externally accessible functions */ 24/* externally accessible functions */
142/** 25/**
143 * Initialize Ecore_File and the services it will use. Call this function 26 * Initialize Ecore_File and the services it will use. Call this function
@@ -242,9 +125,8 @@ ecore_file_is_dir(const char *file)
242 return 0; 125 return 0;
243} 126}
244 127
245#ifndef _WIN32
246static mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; 128static mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
247#endif /* _WIN32 */ 129
248/** 130/**
249 * Create a new directory 131 * Create a new directory
250 * @param dir The name of the directory to create 132 * @param dir The name of the directory to create