unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Set last-modified time of a (local) file?
@ 2004-01-18 21:28 Kai Grossjohann
  2004-01-19 21:31 ` Kevin Rodgers
  0 siblings, 1 reply; 2+ messages in thread
From: Kai Grossjohann @ 2004-01-18 21:28 UTC (permalink / raw)


Is there a way in Emacs to set the last-modified time of a (local)
file?

I need this for Tramp, more specifically for its handling of
copy-file.  If using an inline method, then Tramp works by reading the
contents of the remote file into a buffer, and then using write-region
to write NEWNAME.  But if the KEEP-DATE arg of copy-file is set to t,
then that file written with write-region needs to get another
last-modification timestamp.

(For the case where NEWNAME is remote, I've already written a function
which invokes {/bin,/usr/bin}/touch.)

Kai

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Set last-modified time of a (local) file?
  2004-01-18 21:28 Set last-modified time of a (local) file? Kai Grossjohann
@ 2004-01-19 21:31 ` Kevin Rodgers
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Rodgers @ 2004-01-19 21:31 UTC (permalink / raw)


Kai Grossjohann wrote:

> Is there a way in Emacs to set the last-modified time of a (local)
> file?


Here's how its done by Fcopy_file():

	{
	  EMACS_TIME atime, mtime;
	  EMACS_SET_SECS_USECS (atime, st.st_atime, 0);
	  EMACS_SET_SECS_USECS (mtime, st.st_mtime, 0);
	  if (set_file_times (XSTRING (encoded_newname)->data,
			      atime, mtime))
	    Fsignal (Qfile_date_error,
		     Fcons (build_string ("Cannot set file date"),
			    Fcons (newname, Qnil)));
	}

If set_file_times() were exposed to Lisp, then you would be able to use
it in Tramp.  (If anyone does that, it'd be nice if the ATIME and MTIME
arguments were lists, as returned by file-attributes.)

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-01-19 21:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-18 21:28 Set last-modified time of a (local) file? Kai Grossjohann
2004-01-19 21:31 ` Kevin Rodgers

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).