>>>> "Ben" == Ben Wing <ben(a)666.com>
writes:
Ben> adrian, this is very likely a bug caused by martin, because he
Ben> simply removed the utime support under windows when he reworked
Ben> it. [please be more careful wrt windows, martin!]
Ben, I consider that an unwarranted inflammatory remark.
I may indeed have broken windows somehow, but it was not by removing
windows-specific code.
Ben> here is some code out of my mule workspace that should fix it.
Why can't you just windowsize set_file_times() without changing the
semantics?
set_file_times didn't have windows-specific code previously.
Either it has utimes() or utime(), or we write our own replacement utimes().
In either case set_file_times() doesn't need windows-specific code.
Ben> int mswindows_utime (Lisp_Object path, struct utimbuf *times);
Ben> and this code to nt.c:
Ben> static void
Ben> convert_from_time_t (time_t time, FILETIME * pft)
Ben> {
Ben> long double tmp;
Ben> if (!init)
Ben> {
Ben> /* Determine the delta between 1-Jan-1601 and 1-Jan-1970. */
Ben> SYSTEMTIME st;
Ben> st.wYear = 1970;
Ben> st.wMonth = 1;
Ben> st.wDay = 1;
Ben> st.wHour = 0;
Ben> st.wMinute = 0;
Ben> st.wSecond = 0;
Ben> st.wMilliseconds = 0;
Ben> SystemTimeToFileTime (&st, &utc_base_ft);
Ben> utc_base = (long double) utc_base_ft.dwHighDateTime
Ben> * 4096 * 1024 * 1024 + utc_base_ft.dwLowDateTime;
Ben> init = 1;
Ben> }
Ben> /* time in 100ns units since 1-Jan-1601 */
Ben> tmp = (long double) time * 1e7 + utc_base;
pft-> dwHighDateTime = (DWORD) (tmp / (4096.0 * 1024 * 1024));
pft-> dwLowDateTime = (DWORD) (tmp - (4096.0 * 1024 * 1024) *
pft-> dwHighDateTime);
Ben> }
Ben> int
Ben> mswindows_utime (Lisp_Object path, struct utimbuf *times)
Ben> {
Ben> struct utimbuf deftime;
Ben> HANDLE fh;
Ben> FILETIME mtime;
Ben> FILETIME atime;
Ben> Extbyte *filename;
Ben> if (times == NULL)
Ben> {
Ben> deftime.modtime = deftime.actime = time (NULL);
Ben> times = &deftime;
Ben> }
Ben> LISP_STRING_TO_EXTERNAL (path, filename, Qmswindows_tstr);
Ben> /* Need write access to set times. */
Ben> fh = CreateFile (filename, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
Ben> 0, OPEN_EXISTING, 0, NULL);
Ben> if (fh)
Ben> {
Ben> convert_from_time_t (times->actime, &atime);
Ben> convert_from_time_t (times->modtime, &mtime);
Ben> if (!SetFileTime (fh, NULL, &atime, &mtime))
Ben> {
Ben> CloseHandle (fh);
Ben> errno = EACCES;
Ben> return -1;
Ben> }
Ben> CloseHandle (fh);
Ben> }
Ben> else
Ben> {
Ben> errno = EINVAL;
Ben> return -1;
Ben> }
Ben> return 0;
Ben> }
Ben> Adrian Aichner wrote:
>
> >>>>> "APA" == Adrian Aichner
<Adrian.Aichner(a)t-online.de> writes:
>
APA> Torgny has located the problem.
>
APA> Thanks, Torgny!
>
APA> What is the right approach to fix this?
>
>> Martin,
>
>> you've worked on this last.
>
>> The current code in 21.1.14 does work on Windows
2000 while the code
>> in 21.2-b46 does not!
>
>> I'm willing to test any suggestions you
have.
>
>> Best regards,
>
>> Adrian
>
APA> Best regards,
>
APA> Adrian
>
APA> From: Torgny Nyblom <torgny(a)linux.nu>
APA> Subject: Re: XEmacs 21.1-b46 pop3.el?
APA> Newsgroups: comp.emacs.xemacs
APA> Date: 03 Apr 2001 17:00:07 +0200
APA> Organization: Telenordia
APA> Message-ID: <elvaowp4.fsf(a)nyblom.org>
APA> References: <u24gt9fi.fsf(a)nyblom.org>
<ulmpshzyx.fsf(a)rapier.ecf.teradyne.com>
APA> Xref:
news.t-online.com comp.emacs.xemacs:52365
>
APA> Adrian Aichner <adrian(a)xemacs.org> writes:
>
>> >> FWIW, I have seen this problem also in
21.2-b46 build on native
>> >> Windows 2000.
Torgny> know if the problem exists in others) pop3.el. The problem
Torgny> is that when I try to use 'pop3-leave-mail-on-server t' I
Torgny> get this error message:
>
APA> [...]
>
APA> After some time away I found what the problem is.
In the function
APA> 'pop3-save-uidls' in pop3.el 'copy-file' is called with KEEP-TIME
to 't' this
APA> breaks Win2000. If I remove this 't' everything workes fine.
>
APA> --
APA> Torgny Nyblom | torgny(a)linux.nu
APA> ===============================
APA> My keyboard has an F1 key. Where is the NASCAR key?
APA> ===============================
APA> ----------
>
APA> --
APA> Adrian Aichner Teradyne GmbH, European Design Center
APA> Integra Test Division Telephone +49/89/41861(0)-208
APA> Dingolfinger Strasse 2 Fax +49/89/41861-115
APA> D-81673 MUENCHEN E-mail adrian.aichner(a)teradyne.com
>
>> --
>> Adrian Aichner
>> mailto:adrian@xemacs.org
>>
http://www.xemacs.org/
Ben> --
Ben> ben
Ben> I'm sometimes slow in getting around to reading my mail, so if you
Ben> want to reach me faster, call 520-661-6661.
Ben> See
http://www.666.com/ben/chronic-pain/ for the hell I've been
Ben> through.Index: src/fileio.c
Ben> ===================================================================
Ben> RCS file: /usr/CVSroot/XEmacs/xemacs/src/fileio.c,v
Ben> retrieving revision 1.51.2.34.6.2
Ben> diff -u -r1.51.2.34.6.2 fileio.c
Ben> --- src/fileio.c 2001/02/27 17:21:21 1.51.2.34.6.2
Ben> +++ src/fileio.c 2001/04/05 05:15:23
Ben> @@ -54,6 +54,7 @@
Ben> #endif /* HPUX */
Ben> #ifdef WIN32_NATIVE
Ben> +#include "nt.h"
Ben> #define IS_DRIVE(x) isalpha (x)
Ben> /* Need to lower-case the drive letter, or else expanded
Ben> filenames will sometimes compare inequal, because
Ben> @@ -1676,16 +1667,6 @@
Ben> return;
Ben> }
Ben> -/* A slightly higher-level interface than `set_file_times' */
Ben> -static int
Ben> -lisp_string_set_file_times (Lisp_Object filename,
Ben> - EMACS_TIME atime, EMACS_TIME mtime)
Ben> -{
Ben> - char *ext_filename;
Ben> - LISP_STRING_TO_EXTERNAL (filename, ext_filename, Qfile_name);
Ben> - return set_file_times (ext_filename, atime, mtime);
Ben> -}
Ben> -
Ben> DEFUN ("copy-file", Fcopy_file, 2, 4,
Ben> "fCopy file: \nFCopy %s to file: \np\nP", /*
Ben> Copy FILENAME to NEWNAME. Both args must be strings.
Ben> @@ -1823,7 +1804,7 @@
Ben> EMACS_TIME atime, mtime;
Ben> EMACS_SET_SECS_USECS (atime, st.st_atime, 0);
Ben> EMACS_SET_SECS_USECS (mtime, st.st_mtime, 0);
Ben> - if (lisp_string_set_file_times (newname, atime, mtime))
Ben> + if (set_file_times (newname, atime, mtime))
Ben> report_file_error ("I/O error", list1 (newname));
Ben> }
Ben> chmod ((const char *) XSTRING_DATA (newname),
Ben> Index: src/sysdep.c
Ben> ===================================================================
Ben> RCS file: /usr/CVSroot/XEmacs/xemacs/src/sysdep.c,v
Ben> retrieving revision 1.32.2.44.4.2
Ben> diff -u -r1.32.2.44.4.2 sysdep.c
Ben> --- src/sysdep.c 2001/03/14 16:16:22 1.32.2.44.4.2
Ben> +++ src/sysdep.c 2001/04/05 05:15:57
Ben> @@ -3342,17 +3289,26 @@
Ben> access to those functions goes through the following. */
Ben> int
Ben> -set_file_times (char *filename, EMACS_TIME atime, EMACS_TIME mtime)
Ben> +set_file_times (Lisp_Object path, EMACS_TIME atime, EMACS_TIME mtime)
Ben> {
Ben> -#if defined (HAVE_UTIME)
Ben> +#if defined (WIN32_NATIVE)
Ben> + struct utimbuf utb;
Ben> + utb.actime = EMACS_SECS (atime);
Ben> + utb.modtime = EMACS_SECS (mtime);
Ben> + return mswindows_utime (path, &utb);
Ben> +#elif defined (HAVE_UTIME)
Ben> struct utimbuf utb;
Ben> + Extbyte *filename;
Ben> utb.actime = EMACS_SECS (atime);
Ben> utb.modtime = EMACS_SECS (mtime);
Ben> + LISP_STRING_TO_EXTERNAL (path, filename, Qfile_name);
Ben> return utime (filename, &utb);
Ben> #elif defined (HAVE_UTIMES)
Ben> struct timeval tv[2];
Ben> + Extbyte *filename;
Ben> tv[0] = atime;
Ben> tv[1] = mtime;
Ben> + LISP_STRING_TO_EXTERNAL (path, filename, Qfile_name);
Ben> return utimes (filename, tv);
Ben> #else
Ben> /* No file times setting function available. */
Ben> Index: src/systime.h
Ben> ===================================================================
Ben> RCS file: /usr/CVSroot/XEmacs/xemacs/src/systime.h,v
Ben> retrieving revision 1.8.2.6.6.1
Ben> diff -u -r1.8.2.6.6.1 systime.h
Ben> --- src/systime.h 2001/02/20 12:22:01 1.8.2.6.6.1
Ben> +++ src/systime.h 2001/04/05 05:15:57
Ben> @@ -63,10 +63,16 @@
Ben> #endif /* WIN32_NATIVE */
Ben> +/* struct utimbuf */
Ben> +
Ben> #ifdef HAVE_UTIME
Ben> # include <utime.h>
Ben> #endif
Ben> +#ifdef WIN32_NATIVE
Ben> +# include <sys/utime.h>
Ben> +#endif
Ben> +
Ben> #if defined(HAVE_TZNAME) && !defined(WIN32_NATIVE) &&
!defined(CYGWIN)
Ben> #ifndef tzname /* For SGI. */
Ben> extern char *tzname[]; /* RS6000 and others want it this way. */
Ben> @@ -228,7 +234,7 @@
Ben> #define EMACS_SET_SECS_USECS(time, secs, usecs) \
Ben> (EMACS_SET_SECS (time, secs), EMACS_SET_USECS (time, usecs))
Ben> -int set_file_times (char *filename, EMACS_TIME atime, EMACS_TIME mtime);
Ben> +int set_file_times (Lisp_Object path, EMACS_TIME atime, EMACS_TIME mtime);
Ben> void get_process_times (double *user_time, double *system_time,
Ben> double *real_time);