summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Sadoine <chris@indefini.org>2013-06-19 15:47:20 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-06-25 12:29:27 +0900
commitd9e1b7d67cb278b5ad78128f15ba36f77b04756b (patch)
tree656ccc5cfbc369d9835a112db367e35a9f8869b6
parent4605b91804836878b86de8761b3ae8e81b34ed46 (diff)
evil: added evil_rename() a wrapper around rename().
Signed-off-by: Cedric Bail <cedric.bail@samsung.com>
-rw-r--r--ChangeLog4
-rw-r--r--NEWS1
-rw-r--r--src/lib/evil/evil_stdio.c29
-rw-r--r--src/lib/evil/evil_stdio.h20
4 files changed, 52 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 9ff23e9402..9d02b31f83 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,10 @@
10 10
11 * Evas: optimized path for when map use the same color for all corner. 11 * Evas: optimized path for when map use the same color for all corner.
12 12
132013-06-19 Christophe Sadoine
14
15 * Evil: Added evil_rename function, a wrapper around rename().
16
132013-06-18 Cedric Bail 172013-06-18 Cedric Bail
14 18
15 * Evas: Use Eo array of callbacks to reduce edje memory foot print of Evas_Object_Box and Evas_Object_Table. 19 * Evas: Use Eo array of callbacks to reduce edje memory foot print of Evas_Object_Box and Evas_Object_Table.
diff --git a/NEWS b/NEWS
index cd6dda8868..be1b545a1a 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Additions:
9 * Add --with-api=XXX (both|legacy|eo) 9 * Add --with-api=XXX (both|legacy|eo)
10 * Evil: 10 * Evil:
11 - Add mkdtemp. 11 - Add mkdtemp.
12 - Add evil_rename() a wrapper for rename().
12 * eina: 13 * eina:
13 - Add DOCTYPE children parsing in eina_simple_xml 14 - Add DOCTYPE children parsing in eina_simple_xml
14 - Add eina_barrier thread API 15 - Add eina_barrier thread API
diff --git a/src/lib/evil/evil_stdio.c b/src/lib/evil/evil_stdio.c
index 231e5043d6..dd800041f8 100644
--- a/src/lib/evil/evil_stdio.c
+++ b/src/lib/evil/evil_stdio.c
@@ -6,7 +6,7 @@
6#include "evil_private.h" 6#include "evil_private.h"
7 7
8#undef fopen 8#undef fopen
9 9#undef rename
10 10
11#ifdef _WIN32_WCE 11#ifdef _WIN32_WCE
12 12
@@ -199,3 +199,30 @@ int evil_fclose_native(FILE *stream)
199} 199}
200 200
201#endif /* _WIN32_WCE */ 201#endif /* _WIN32_WCE */
202
203int
204evil_rename(const char *src, const char* dst)
205{
206 struct stat st;
207
208 if (stat(dst, &st) < 0)
209 return rename(src, dst);
210
211 if (stat(src, &st) < 0)
212 return -1;
213
214 if (S_ISDIR(st.st_mode))
215 {
216 rmdir(dst);
217 return rename(src, dst);
218 }
219
220 if (S_ISREG(st.st_mode))
221 {
222 unlink(dst);
223 return rename(src, dst);
224 }
225
226 return -1;
227}
228
diff --git a/src/lib/evil/evil_stdio.h b/src/lib/evil/evil_stdio.h
index 0baf00f5b8..27c116e9c5 100644
--- a/src/lib/evil/evil_stdio.h
+++ b/src/lib/evil/evil_stdio.h
@@ -204,8 +204,26 @@ EAPI int evil_fclose_native(FILE *stream);
204 204
205 205
206/** 206/**
207 * @} 207 * @brief Emulate the rename() function on Windows.
208 *
209 * @param src The old pathname.
210 * @param dst The new pathname.
211 * @return 0 on success, -1 otherwise.
212 *
213 * This function emulates the POSIX rename() function on Windows.
214 * The difference with the POSIX function is that the rename() function
215 * on windows fails if the destination exists.
216 *
217 * @since 1.8
218 */
219EAPI int evil_rename(const char *src, const char *dst);
220
221/**
222 * @def rename(src, dest)
223 *
224 * Wrapper around evil_rename().
208 */ 225 */
226# define rename(src, dst) evil_rename(src, dst)
209 227
210 228
211#endif /* __EVIL_STDIO_H__ */ 229#endif /* __EVIL_STDIO_H__ */