forked from enlightenment/efl
evil: added evil_rename() a wrapper around rename().
Signed-off-by: Cedric Bail <cedric.bail@samsung.com>
This commit is contained in:
parent
4605b91804
commit
d9e1b7d67c
|
@ -10,6 +10,10 @@
|
|||
|
||||
* Evas: optimized path for when map use the same color for all corner.
|
||||
|
||||
2013-06-19 Christophe Sadoine
|
||||
|
||||
* Evil: Added evil_rename function, a wrapper around rename().
|
||||
|
||||
2013-06-18 Cedric Bail
|
||||
|
||||
* Evas: Use Eo array of callbacks to reduce edje memory foot print of Evas_Object_Box and Evas_Object_Table.
|
||||
|
|
1
NEWS
1
NEWS
|
@ -9,6 +9,7 @@ Additions:
|
|||
* Add --with-api=XXX (both|legacy|eo)
|
||||
* Evil:
|
||||
- Add mkdtemp.
|
||||
- Add evil_rename() a wrapper for rename().
|
||||
* eina:
|
||||
- Add DOCTYPE children parsing in eina_simple_xml
|
||||
- Add eina_barrier thread API
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "evil_private.h"
|
||||
|
||||
#undef fopen
|
||||
|
||||
#undef rename
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
|
||||
|
@ -199,3 +199,30 @@ int evil_fclose_native(FILE *stream)
|
|||
}
|
||||
|
||||
#endif /* _WIN32_WCE */
|
||||
|
||||
int
|
||||
evil_rename(const char *src, const char* dst)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat(dst, &st) < 0)
|
||||
return rename(src, dst);
|
||||
|
||||
if (stat(src, &st) < 0)
|
||||
return -1;
|
||||
|
||||
if (S_ISDIR(st.st_mode))
|
||||
{
|
||||
rmdir(dst);
|
||||
return rename(src, dst);
|
||||
}
|
||||
|
||||
if (S_ISREG(st.st_mode))
|
||||
{
|
||||
unlink(dst);
|
||||
return rename(src, dst);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -204,8 +204,26 @@ EAPI int evil_fclose_native(FILE *stream);
|
|||
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @brief Emulate the rename() function on Windows.
|
||||
*
|
||||
* @param src The old pathname.
|
||||
* @param dst The new pathname.
|
||||
* @return 0 on success, -1 otherwise.
|
||||
*
|
||||
* This function emulates the POSIX rename() function on Windows.
|
||||
* The difference with the POSIX function is that the rename() function
|
||||
* on windows fails if the destination exists.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
EAPI int evil_rename(const char *src, const char *dst);
|
||||
|
||||
/**
|
||||
* @def rename(src, dest)
|
||||
*
|
||||
* Wrapper around evil_rename().
|
||||
*/
|
||||
# define rename(src, dst) evil_rename(src, dst)
|
||||
|
||||
|
||||
#endif /* __EVIL_STDIO_H__ */
|
||||
|
|
Loading…
Reference in New Issue