Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Preserving File Timestamps

From: greggirwin:mindspring at: 13-May-2004 10:32

C> Some months ago, there was a discussion here about maintaining file C> timestamps when copying files with REBOL's write %copy read %source. C> Was the resolution that it can be done? If so, what achieves this? Below are a couple attribute related functions I wrote a long time ago. -- Gregg (watch for wrap) touch: func [ {Set the modification timestamp of the file.} files [file! block!] "The file, or files, you want to stamp" /with "Use a specified time rather than the current time." time [date!] "The date and time to stamp them with" /local rd-only ][ if not with [time: now] ; We have to turn off the read-only attribute if it's on. foreach item compose [(files)] [ rd-only: not get-modes item 'owner-write set-modes to-file item [owner-write: true modification-date: time] if rd-only [set-modes item [owner-write: false]] ] ; Should we return the time, even though it may not match the actual ; stamp on the files due to OS differences? ;time ] attr: func [ {Return current attributes for the file.} file [file!] /with {Retrieve only selected attributes.} sel {Selected attributes to retrieve.} /avail {Return a list of attributes available for the file.} /copy {Copy all attributes, which are safe to copy, to f2.} f2 [file!] /local a ][ if with [return get-modes file sel] if avail [return get-modes file 'file-modes] if copy [ ;set-modes f2 a: get-modes file get-modes file 'copy-modes ; Core 2.5 includes full-path, which it shouldn't ;set-modes f2 a: get-modes file exclude get-modes file 'copy-modes [full-path] set-modes f2 a: get-modes file get-modes file 'copy-modes return a ] get-modes file get-modes file 'file-modes ]