used utime and utimes as a fallback in fs-copy.c

This commit is contained in:
hyung-hwan 2015-02-03 02:26:32 +00:00
parent ac6661de94
commit 67a5f4f5f5
3 changed files with 53 additions and 14 deletions

View File

@ -504,14 +504,15 @@ static int expand_wildcard (int argc, qse_char_t* argv[], int glob, xarg_t* xarg
if (glob)
{
x = qse_glob (argv[i], collect_into_xarg, xarg,
QSE_GLOB_TOLERANT |
#if defined(_WIN32) || defined(__OS2__) || defined(__DOS__)
QSE_GLOB_NOESCAPE | QSE_GLOB_PERIOD | QSE_GLOB_IGNORECASE,
#else
QSE_GLOB_PERIOD,
#endif
xarg->mmgr, qse_getdflcmgr()
#if defined(_WIN32) || defined(__OS2__) || defined(__DOS__)
int glob_flags = QSE_GLOB_TOLERANT | QSE_GLOB_PERIOD | QSE_GLOB_NOESCAPE | QSE_GLOB_IGNORECASE;
#else
int glob_flags = QSE_GLOB_TOLERANT | QSE_GLOB_PERIOD;
#endif
x = qse_glob (
argv[i], collect_into_xarg, xarg,
glob_flags, xarg->mmgr, qse_getdflcmgr()
);
if (x <= -1) return -1;
}

View File

@ -674,12 +674,15 @@ static int expand_wildcards (int argc, qse_char_t* argv[], int glob, xarg_t* xar
if (glob)
{
x = qse_glob (argv[i], collect_into_xarg, xarg,
#if defined(_WIN32) || defined(__OS2__) || defined(__DOS__)
QSE_GLOB_NOESCAPE | QSE_GLOB_IGNORECASE |
int glob_flags = QSE_GLOB_TOLERANT | QSE_GLOB_PERIOD | QSE_GLOB_NOESCAPE | QSE_GLOB_IGNORECASE;
#else
int glob_flags = QSE_GLOB_TOLERANT | QSE_GLOB_PERIOD;
#endif
QSE_GLOB_TOLERANT | QSE_GLOB_PERIOD,
xarg->mmgr, qse_getdflcmgr()
x = qse_glob (
argv[i], collect_into_xarg, xarg,
glob_flags, xarg->mmgr, qse_getdflcmgr()
);
if (x <= -1) return -1;

View File

@ -241,16 +241,22 @@ static int copy_file_in_fs (qse_fs_t* fs, cpfile_t* cpfile)
struct timespec ts[2];
#elif defined(HAVE_FUTIMES)
struct timeval tv[2];
#elif defined(HAVE_UTIME)
struct utimbuf ub;
#elif defined(HAVE_UTIMES)
struct timeval tv[2];
#endif
if (QSE_FCHOWN (out, cpfile->src_attr.uid, cpfile->src_attr.gid) <= -1 ||
QSE_FCHMOD (out, cpfile->src_attr.mode) <= -1)
QSE_FCHMOD (out, cpfile->src_attr.mode) <= -1)
{
fs->errnum = qse_fs_syserrtoerrnum (fs, errno);
goto oops;
}
#if defined(HAVE_FUTIMENS)
QSE_MEMSET (&ts, 0, QSE_SIZEOF(ts));
ts[0].tv_sec = cpfile->src_attr.atime.sec;
ts[0].tv_nsec = cpfile->src_attr.atime.nsec;
ts[1].tv_sec = cpfile->src_attr.mtime.sec;
@ -260,7 +266,10 @@ static int copy_file_in_fs (qse_fs_t* fs, cpfile_t* cpfile)
fs->errnum = qse_fs_syserrtoerrnum (fs, errno);
goto oops;
}
#elif defined(HAVE_FUTIMES)
QSE_MEMSET (&tv, 0, QSE_SIZEOF(tv));
tv[0].tv_sec = cpfile->src_attr.atime.sec;
tv[0].tv_usec = QSE_NSEC_TO_USEC(cpfile->src_attr.atime.nsec);
tv[1].tv_sec = cpfile->src_attr.mtime.sec;
@ -270,8 +279,34 @@ static int copy_file_in_fs (qse_fs_t* fs, cpfile_t* cpfile)
fs->errnum = qse_fs_syserrtoerrnum (fs, errno);
goto oops;
}
#elif defined(HAVE_UTIME)
QSE_MEMSET (&ub, 0, QSE_SIZEOF(ub));
ub.actime = cpfile->src_attr.atime.sec;
ub.modtime = cpfile->src_attr.mtime.sec;
if (QSE_UTIME (cpfile->dst_fspath, &ub) <= -1)
{
fs->errnum = qse_fs_syserrtoerrnum (fs, errno);
goto oops;
}
#elif defined(HAVE_UTIMES)
QSE_MEMSET (&tv, 0, QSE_SIZEOF(tv));
tv[0].tv_sec = cpfile->src_attr.atime.sec;
tv[0].tv_usec = QSE_NSEC_TO_USEC(cpfile->src_attr.atime.nsec);
tv[1].tv_sec = cpfile->src_attr.mtime.sec;
tv[1].tv_usec = QSE_NSEC_TO_USEC(cpfile->src_attr.mtime.nsec);
// work on the file name not on the file descriptor.
if (QSE_UTIMES (cpfile->dst_fspath, tv) <= -1)
{
fs->errnum = qse_fs_syserrtoerrnum (fs, errno);
goto oops;
}
#else
# error neither futimens nor futimes exist
# error none of futimens, futimes, utime, utimes exist
#endif
}