2008-10-11 07:35:26 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif /* HAVE_CONFIG_H */
|
|
|
|
|
2015-07-02 23:14:01 -07:00
|
|
|
#include <direct.h>
|
2015-12-07 20:53:23 -08:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
2015-07-02 23:14:01 -07:00
|
|
|
|
2015-12-07 20:53:23 -08:00
|
|
|
#include "evil_macro.h"
|
|
|
|
#include "evil_stdio.h"
|
2008-11-21 14:57:45 -08:00
|
|
|
#include "evil_private.h"
|
|
|
|
|
2013-06-18 23:47:20 -07:00
|
|
|
#undef rename
|
2008-10-11 07:35:26 -07:00
|
|
|
|
2013-06-18 23:47:20 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-07-02 23:14:01 -07:00
|
|
|
int
|
|
|
|
evil_mkdir(const char *dirname, mode_t mode EVIL_UNUSED)
|
|
|
|
{
|
|
|
|
return _mkdir(dirname);
|
|
|
|
}
|
|
|
|
|