Hi i use:
http://www.newlisp.org/downloads/newlisp_manual.html#write-file
To uppdate textfiles, but i don't want the "Date modified" uppdated.
Can I do that in some way?
Yes, by writing your own filesystem :)
I've no clue of how to do it in newLisp, but since the 'touch' utility does it all of the time, I don't think you would have to 'rewrite' the OS...
--hsm
I would try something like:
(set 'mod-date (date (file-info item 6) 0 "%Y%m%d%H%M.%S"))
; modify item
(exec (string "touch -t " mod-date " " item))
or something. Presumably there's a 'touch' command on Windows...
Quote from: "cormullion"
Presumably there's a 'touch' command on Windows...
No, there isn't. However Lutz' coding of file-info for retrieving the data might show the way to set the data.
Windows doesn't come with 'touch'--- but it is widely available on the net. I've never thought about it since I've always had it in my toolkit as a developer. It is trivial to write. Seems to me that in the long ago days one came with the Borland dev kits. Not having it is sort of like not having grep ;)
--hsm
Hi and thanx for you replys.
So what you say is that one solution is to, get a touch for Windows and then read the "Date modified" value, uppdate the file and then set back the value afterwards.
Will maybe try fixing that.
edit: Maybe I can use the version of touch from: http://gnuwin32.sourceforge.net/packages/coreutils.htm
aron,
Actually I'd do both--- first acquire a working 'touch'. The one you point to is a good one, as are the rest of their Unix tools; get them all, you will need them sooner or later. Second, see if newLISP can solve your problem by trying the other suggestions made here. It will teach you more about both newLISP and the file system. Both worth knowing.
--hsm
If your target is Windows, you could also wield the win32api directly through (import) (//http).
Here is a page showing what win32api functions do what (written in Visual Basic).
http://vbnet.mvps.org/code/fileapi/filedatetime.htm
While I suppose you could go through the Win32 API, here is all you really need:
INT 21 Function 5701h:SET FILE'S LAST-WRITTEN DATE AND TIME
AX = 5701h
BX = file handle
CX = new time
DX = new date
Return:
CF clear if successful CF set on error AX = error code (01h,06h)
Bitfields for file time:
Bit(s) Description
15-11 hours (0-23)
10-5 minutes
4-0 seconds/2
Bitfields for file date:
Bit(s) Description
15-9 year - 1980
8-5 month
4-0 day
1. write dll in assembler
2. write glue in newLISP
3. use
--hsm
p.s. note that this function is handle based, so you will have to open the file you want to touch. Probably could get away without closing, but to be safe, call the close function as well.
Quote from: "hsmyers"
INT 21 Function
You can still do that? O_O
Wow...
But shouldn't there be POSIX functions that can modify a file's Last Modified date? I suppose that would be the most cross-platform approach.
Quote from: "m35"
Quote from: "hsmyers"
INT 21 Function
You can still do that? O_O
Yes, the interrupts still work, but it is frowned upon to use them. MS claims they may not be reliable anymore.