forked from enlightenment/efl
parent
e45ff14147
commit
a22ebcafac
|
@ -86,15 +86,18 @@ AC_CHECK_HEADERS(netinet/in.h)
|
|||
|
||||
winsock_libs=""
|
||||
create_shared_lib=""
|
||||
ecore_file_win32_lib=""
|
||||
case "$host_os" in
|
||||
mingw|mingw32)
|
||||
winsock_libs="-lwsock32"
|
||||
create_shared_lib="-no-undefined"
|
||||
ecore_file_win32_lib="-lole32 -luuid"
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_SUBST(winsock_libs)
|
||||
AC_SUBST(create_shared_lib)
|
||||
AC_SUBST(ecore_file_win32_lib)
|
||||
|
||||
iconv_cflags=""
|
||||
iconv_libs=""
|
||||
|
|
|
@ -5,7 +5,7 @@ INCLUDES = \
|
|||
-I$(top_builddir)/src/lib/ecore \
|
||||
@CURL_CFLAGS@
|
||||
|
||||
libecore_file_la_LDFLAGS = -version-info 1:0:0 \
|
||||
libecore_file_la_LDFLAGS = @create_shared_lib@ -version-info 1:0:0 \
|
||||
-L$(top_builddir)/src/lib/ecore/.libs
|
||||
|
||||
if BUILD_ECORE_FILE
|
||||
|
@ -25,7 +25,7 @@ ecore_file_download.c
|
|||
|
||||
libecore_file_la_LIBADD = \
|
||||
$(top_builddir)/src/lib/ecore/libecore.la \
|
||||
@fam_libs@ @CURL_LIBS@
|
||||
@fam_libs@ @CURL_LIBS@ @ecore_file_win32_lib@
|
||||
|
||||
endif
|
||||
|
||||
|
|
|
@ -3,19 +3,78 @@
|
|||
*/
|
||||
|
||||
#ifndef _FILE_OFFSET_BITS
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
# define _FILE_OFFSET_BITS 64
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include <features.h>
|
||||
# include <features.h>
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
#include "ecore_file_private.h"
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
# include <shlobj.h>
|
||||
# include <objidl.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
|
||||
static int init = 0;
|
||||
|
||||
/* FIXME: Windows has no symbolic link. */
|
||||
/* Nevertheless, it can creates .lnk files */
|
||||
#ifdef _WIN32
|
||||
static int
|
||||
symlink (const char *oldpath, const char *newpath)
|
||||
{
|
||||
IShellLink *pISL;
|
||||
IShellLink **shell_link;
|
||||
IPersistFile *pIPF;
|
||||
IPersistFile **persit_file;
|
||||
wchar_t new_path[MB_CUR_MAX];
|
||||
|
||||
/* Hack to cleanly remove a warning */
|
||||
shell_link = &pISL;
|
||||
if (FAILED(CoInitialize(NULL)))
|
||||
return -1;
|
||||
|
||||
if (FAILED(CoCreateInstance(&CLSID_ShellLink,
|
||||
NULL,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
&IID_IShellLink,
|
||||
(void **)shell_link)))
|
||||
goto no_instance;
|
||||
|
||||
if (FAILED(pISL->lpVtbl->SetPath(pISL, oldpath)))
|
||||
goto no_setpath;
|
||||
|
||||
/* Hack to cleanly remove a warning */
|
||||
persit_file = &pIPF;
|
||||
if (FAILED(pISL->lpVtbl->QueryInterface(pISL, &IID_IPersistFile, (void **)persit_file)))
|
||||
goto no_queryinterface;
|
||||
|
||||
mbstowcs(new_path, newpath, MB_CUR_MAX);
|
||||
if (FAILED(pIPF->lpVtbl->Save(pIPF, new_path, FALSE)))
|
||||
goto no_save;
|
||||
|
||||
pIPF->lpVtbl->Release(pIPF);
|
||||
pISL->lpVtbl->Release(pISL);
|
||||
CoUninitialize();
|
||||
|
||||
return 0;
|
||||
|
||||
no_save:
|
||||
pIPF->lpVtbl->Release(pIPF);
|
||||
no_queryinterface:
|
||||
no_setpath:
|
||||
pISL->lpVtbl->Release(pISL);
|
||||
no_instance:
|
||||
CoUninitialize();
|
||||
return -1;
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/* externally accessible functions */
|
||||
/**
|
||||
* Initialize Ecore_File and the services it will use. Call this function
|
||||
|
@ -120,7 +179,9 @@ ecore_file_is_dir(const char *file)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
static mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
|
||||
#endif /* _WIN32 */
|
||||
/**
|
||||
* Create a new directory
|
||||
* @param dir The name of the directory to create
|
||||
|
@ -131,7 +192,11 @@ static mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S
|
|||
EAPI int
|
||||
ecore_file_mkdir(const char *dir)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
if (mkdir(dir, default_mode) < 0) return 0;
|
||||
#else
|
||||
if (mkdir(dir) < 0) return 0;
|
||||
#endif /* _WIN32 */
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -171,14 +236,21 @@ ecore_file_recursive_rm(const char *dir)
|
|||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
char path[PATH_MAX], buf[PATH_MAX];;
|
||||
char path[PATH_MAX];
|
||||
#ifndef _WIN32
|
||||
char buf[PATH_MAX];
|
||||
#endif /* _WIN32 */
|
||||
struct stat st;
|
||||
int ret;
|
||||
|
||||
/* On Windows, no link */
|
||||
#ifndef _WIN32
|
||||
if (readlink(dir, buf, sizeof(buf)) > 0)
|
||||
{
|
||||
return ecore_file_unlink(dir);
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
ret = stat(dir, &st);
|
||||
if ((ret == 0) && (S_ISDIR(st.st_mode)))
|
||||
{
|
||||
|
@ -258,8 +330,13 @@ ecore_file_cp(const char *src, const char *dst)
|
|||
size_t num;
|
||||
int ret = 1;
|
||||
|
||||
#ifndef _WIN32
|
||||
if (!realpath(src, realpath1)) return 0;
|
||||
if (realpath(dst, realpath2) && !strcmp(realpath1, realpath2)) return 0;
|
||||
#else
|
||||
if (!_fullpath(realpath1, src, _MAX_PATH)) return 0;
|
||||
if (_fullpath(realpath2, dst, _MAX_PATH) && !strcmp(realpath1, realpath2)) return 0;
|
||||
#endif /* _WIN32 */
|
||||
|
||||
f1 = fopen(src, "rb");
|
||||
if (!f1) return 0;
|
||||
|
@ -318,6 +395,7 @@ EAPI int
|
|||
ecore_file_symlink(const char *src, const char *dest)
|
||||
{
|
||||
if (!symlink(src, dest)) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -332,7 +410,12 @@ ecore_file_realpath(const char *file)
|
|||
{
|
||||
char buf[PATH_MAX];
|
||||
|
||||
#ifndef _WIN32
|
||||
if (!realpath(file, buf)) return strdup("");
|
||||
#else
|
||||
if (!_fullpath(buf, file, _MAX_PATH)) return strdup("");
|
||||
#endif /* _WIN32 */
|
||||
|
||||
return strdup(buf);
|
||||
}
|
||||
|
||||
|
@ -423,12 +506,16 @@ ecore_file_can_exec(const char *file)
|
|||
EAPI char *
|
||||
ecore_file_readlink(const char *link)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
char buf[PATH_MAX];
|
||||
int count;
|
||||
|
||||
if ((count = readlink(link, buf, sizeof(buf))) < 0) return NULL;
|
||||
buf[count] = 0;
|
||||
return strdup(buf);
|
||||
#else
|
||||
return NULL;
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue