DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Set File Timestamp

  • submit to reddit
    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 read-only?
        if not with [time: now]
        ; We have to turn off the read-only attribute if it's on.
        foreach item compose [(files)] [
            read-only?: not get-modes item 'owner-write
            set-modes to-file item [owner-write: true modification-date: time]
            if read-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?