summaryrefslogtreecommitdiff
path: root/src/lib/evil
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2017-11-10 13:13:06 -0800
committerCedric BAIL <cedric@osg.samsung.com>2017-11-10 13:13:44 -0800
commitb5333edd3ffe8c0379170a0e9d08ee05af439e2c (patch)
tree2baf5d8bf4e1ccecb5576a0f18a1be6f252f698e /src/lib/evil
parentde9cf5a217557a62fb33176492218eb2f8e37e92 (diff)
evil: add tests for Windows port.
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/lib/evil')
-rw-r--r--src/lib/evil/evil_stdio.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/lib/evil/evil_stdio.c b/src/lib/evil/evil_stdio.c
index 5919d0c..6b71e92 100644
--- a/src/lib/evil/evil_stdio.c
+++ b/src/lib/evil/evil_stdio.c
@@ -2,9 +2,14 @@
2# include "config.h" 2# include "config.h"
3#endif /* HAVE_CONFIG_H */ 3#endif /* HAVE_CONFIG_H */
4 4
5#include <direct.h>
6#include <sys/stat.h>
7#include <sys/types.h> 5#include <sys/types.h>
6#include <direct.h>
7
8#ifndef WIN32_LEAN_AND_MEAN
9# define WIN32_LEAN_AND_MEAN
10#endif
11#include <windows.h>
12#undef WIN32_LEAN_AND_MEAN
8 13
9#include "evil_macro.h" 14#include "evil_macro.h"
10#include "evil_stdio.h" 15#include "evil_stdio.h"
@@ -12,30 +17,19 @@
12 17
13#undef rename 18#undef rename
14 19
15int 20int
16evil_rename(const char *src, const char* dst) 21evil_rename(const char *src, const char* dst)
17{ 22{
18 struct stat st; 23 DWORD res;
19
20 if (stat(dst, &st) < 0)
21 return rename(src, dst);
22
23 if (stat(src, &st) < 0)
24 return -1;
25
26 if (S_ISDIR(st.st_mode))
27 {
28 rmdir(dst);
29 return rename(src, dst);
30 }
31 24
32 if (S_ISREG(st.st_mode)) 25 res = GetFileAttributes(dst);
26 if ((res != 0xffffffff) && (res & FILE_ATTRIBUTE_DIRECTORY))
33 { 27 {
34 unlink(dst); 28 if (!RemoveDirectory(dst))
35 return rename(src, dst); 29 return -1;
36 } 30 }
37 31
38 return -1; 32 return MoveFileEx(src, dst, MOVEFILE_REPLACE_EXISTING) ? 0 : -1;
39} 33}
40 34
41int 35int