Task

Get and set the modification time of a file.




/* NetRexx */
options replace format comments java crossref symbols binary
 
runSample(arg)
return
 
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) public static
  parse arg fileName
  if fileName = '' then fileName = 'data/tempfile01'
  mfile = File(fileName)
  mtime = mfile.lastModified()
  dtime = Date(mtime).toString()
  say 'File' fileName 'last modified at' dtime
  say
  if mfile.setLastModified(0) then do
    dtime = Date(mfile.lastModified()).toString()
    say 'File modification time altered...'
    say 'File' fileName 'now last modified at' dtime
    say
    say 'Resetting...'
    mfile.setLastModified(mtime)
    dtime = Date(mfile.lastModified()).toString()
    say 'File' fileName 'reset to last modified at' dtime    
    end
  else do
    say 'Unable to modify time for file' fileName
    end
  return
 