Product SiteDocumentation Site

5.4.25.19. lastModified (Attribute)


>>-lastModified------------------------------------------------><

>>-lastModified=date-------------------------------------------><

lastModified get:
Returns the last modified date of the file/directory denoted by the absolute path of the receiver object. The result is a DateTime object, or .nil in case of error.
lastModified set:
Sets the last modified date of the file/directory denoted by the absolute path of the receiver object.
The date parameter is a DateTime object.
Examples:

Example 5.209. Class FILE - lastModified method

    
    /* On Windows */
    say .File~new("C:\Program Files")~lastModified~class    -- The DateTime class
    say .File~new("C:\Program Files")~lastModified          -- 2010-11-01T19:14:49.000000
    say .File~new("dummy")~lastModified                     -- The NIL object

    /* A possible implementation of : touch -c -m -r referenceFile file
       -c, --no-create             do not create any files
       -m                          change only the modification time
       -r, --reference=FILE        use this file's time instead of current time
    */
    parse arg referenceFilePath filePath .
    file = .File~new(filePath)
    if \ file~exists then return 0 -- OK, not an error
    referenceFile = .File~new(referenceFilePath)
    referenceDate = referenceFile~lastModified
    if referenceDate == .nil then return 1 -- KO
    file~lastModified = referenceDate
    return 0 -- OK