comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Linux-like touch command in IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Linux-like touch command in IDL [message #90232 is a reply to message #90223] Thu, 12 February 2015 13:14 Go to previous messageGo to previous message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
> Does /APPEND solve this?

No, adding /APPEND does not change [ACM]TIME (see below). The following also do not change [ACM]TIME.

File_Move, path, path, /ALLOW_SAME
File_Copy, path, path, /ALLOW_SAME

OpenR, lun, filename, /GET_LUN
free_lun, lun

I thought at least the last operation would change ATIME, but it doesn't. On the otherhand, the following changes ATIME

nLines = File_Lines(path)

So, I thought I maybe the file pointer needed to be moved, but this did not change ATIME either

openr, lun, path, /GET_LUN
point_lun, lun, 1
free_lun, lun

Finally, I tried reading on byte of data, which did change ATIME.

var = 0B
openr, lun, path, /GET_LUN
readu, lun, var

Below is an updated version of touch.pro. Since the same technique does not work with directories, I am left with creating a temporary file and deleting it. This changes all three of [ACM]TIME.

---------------------------------------------


pro touch, path
on_error, 2

;Directory -- Updates access, status change, and modified times.
if file_test(path, /DIRECTORY, /WRITE) then begin
temp_file = filepath('touch_temp_file.txt', ROOT_DIR=path)
openw, lun, temp_file, /GET_LUN
free_lun, lun
file_delete, temp_file

;File -- updates access time
endif else if file_test(path, /READ) then begin
var = 0B
openr, lun, path, /GET_LUN
readu, lun, var

;Other
endif else begin
message, 'PATH must be a file with read privileges or a directory with write privileges.'
endelse
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: EDG: Using IDL_MakeTempStruct() vs. IDL_ImportArray()
Next Topic: Variable attributes and undef vars

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:31:49 PDT 2025

Total time taken to generate the page: 0.00361 seconds