diff options
author | Karl Berry <karl@freefriends.org> | 2008-05-15 14:16:57 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2008-05-15 14:16:57 +0000 |
commit | dfead18ba1f89b3f1da371199dff37f08a4a4200 (patch) | |
tree | ac6e95b933b4f7dfae5fc55919ab7a6f2b365f7f /Build/source/utils/lzma-utils/src/lzma/lzmp.cpp | |
parent | 9fc9c79b5aafe872a4da1fe59564b2a60aecb2ca (diff) |
lzma-utils 4.32.6 from http://tukaani.org/lzma/download
git-svn-id: svn://tug.org/texlive/trunk@8158 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/lzma-utils/src/lzma/lzmp.cpp')
-rw-r--r-- | Build/source/utils/lzma-utils/src/lzma/lzmp.cpp | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/Build/source/utils/lzma-utils/src/lzma/lzmp.cpp b/Build/source/utils/lzma-utils/src/lzma/lzmp.cpp index 50725b56b04..9ba85f81745 100644 --- a/Build/source/utils/lzma-utils/src/lzma/lzmp.cpp +++ b/Build/source/utils/lzma-utils/src/lzma/lzmp.cpp @@ -49,16 +49,6 @@ typedef vector<string> stringVector; #include <utime.h> #include <sys/time.h> // futimes() -// Solaris has futimesat() instead of futimes() and some systems -// don't have anything appropriate. -#ifndef HAVE_FUTIMES -# ifdef HAVE_FUTIMESAT -# define futimes(fd, tv) futimesat(fd, NULL, tv) -# else -# define futimes(fd, tv) 0 -# endif -#endif - #if defined(_WIN32) || defined(OS2) || defined(MSDOS) #include <fcntl.h> #include <io.h> @@ -98,7 +88,7 @@ struct lzma_option { short compression_mode; // -a short dictionary; // -d short fast_bytes; // -fb - wchar_t *match_finder; // -mf + const wchar_t *match_finder; // -mf short literal_context_bits; // -lc short literal_pos_bits; // -lp short pos_bits; // -pb @@ -121,8 +111,8 @@ const lzma_option option_mapping[] = { }; struct extension_pair { - char *from; - char *to; + const char *from; + const char *to; }; const extension_pair known_extensions[] = { @@ -654,6 +644,32 @@ open_stdxxx(int status) return; } +static void +my_utimes(const char *name, int fd, time_t atime, time_t mtime) +{ +#if defined(HAVE_FUTIMES) || defined(HAVE_FUTIMESAT) || defined(HAVE_UTIMES) + // This could use subsecond precision, but it's not portably available + // in struct stat, so that feature has to wait for LZMA Utils 5. + struct timeval file_times[2]; + file_times[0].tv_sec = atime; + file_times[0].tv_usec = 0; + file_times[1].tv_sec = mtime; + file_times[1].tv_usec = 0; + +# if defined(HAVE_FUTIMES) + (void)futimes(fd, file_times); +# elif defined(HAVE_FUTIMESAT) + (void)futimesat(fd, NULL, file_times); +# else + (void)utimes(name, file_times); +# endif + +#elif defined(HAVE_UTIME) + struct utimbuf file_times = { atime, mtime }; + (void)utime(name, &file_times); +#endif +} + } // namespace lzma @@ -910,15 +926,8 @@ int main(int argc, char **argv) (void)fchmod(outhandle, mode); - struct timeval file_times[2]; - // Access time - file_times[0].tv_sec = in_stats.st_atime; - file_times[0].tv_usec = 0; - // Modification time - file_times[1].tv_sec = in_stats.st_mtime; - file_times[1].tv_usec = 0; - - (void)futimes(outhandle, file_times); + my_utimes(output_filename.c_str(), outhandle, + in_stats.st_atime, in_stats.st_mtime); } // Check that closing the output stream succeeds. |