mirror of https://github.com/aria2/aria2
Use utimes instead of utime if utimes is available.
parent
3fe4e84443
commit
af46293ef9
|
@ -400,7 +400,8 @@ AC_CHECK_FUNCS([__argz_count \
|
||||||
tzset \
|
tzset \
|
||||||
unsetenv \
|
unsetenv \
|
||||||
usleep \
|
usleep \
|
||||||
utime])
|
utime \
|
||||||
|
utimes])
|
||||||
|
|
||||||
if test "x$enable_epoll" = "xyes"; then
|
if test "x$enable_epoll" = "xyes"; then
|
||||||
AC_CHECK_FUNCS([epoll_create], [have_epoll=yes])
|
AC_CHECK_FUNCS([epoll_create], [have_epoll=yes])
|
||||||
|
|
12
src/File.cc
12
src/File.cc
|
@ -36,7 +36,9 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <utime.h>
|
#ifdef HAVE_UTIME_H
|
||||||
|
# include <utime.h>
|
||||||
|
#endif // HAVE_UTIME_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -218,10 +220,18 @@ bool File::renameTo(const std::string& dest)
|
||||||
|
|
||||||
bool File::utime(const Time& actime, const Time& modtime) const
|
bool File::utime(const Time& actime, const Time& modtime) const
|
||||||
{
|
{
|
||||||
|
#if defined HAVE_UTIMES && !(defined __MINGW32__)
|
||||||
|
struct timeval times[2] = {
|
||||||
|
{ actime.getTime(), 0 },
|
||||||
|
{ modtime.getTime(), 0 }
|
||||||
|
};
|
||||||
|
return utimes(name_.c_str(), times) == 0;
|
||||||
|
#else // !HAVE_UTIMES
|
||||||
a2utimbuf ub;
|
a2utimbuf ub;
|
||||||
ub.actime = actime.getTime();
|
ub.actime = actime.getTime();
|
||||||
ub.modtime = modtime.getTime();
|
ub.modtime = modtime.getTime();
|
||||||
return a2utime(utf8ToWChar(name_).c_str(), &ub) == 0;
|
return a2utime(utf8ToWChar(name_).c_str(), &ub) == 0;
|
||||||
|
#endif // !HAVE_UTIMES
|
||||||
}
|
}
|
||||||
|
|
||||||
Time File::getModifiedTime()
|
Time File::getModifiedTime()
|
||||||
|
|
Loading…
Reference in New Issue