replacement for dos_filedate

replacement for dos_filedate

HE-MJJ
Advocate Advocate
1,824 Views
25 Replies
Message 1 of 26

replacement for dos_filedate

HE-MJJ
Advocate
Advocate

I'm trying find a replacement for dos_filedate.

 

I thought by using vl-file-systime, but vl-file-systime apparently does not return a value of a file that is opened which dos_filedate does. As you can see in results below:

 

_$ (vl-file-systime "H:\\0000\\0000\\Tekeningen\\BT\\0000_BT-BB-022A.dwg")
nil
_$ (vl-file-systime "H:\\0000\\0000\\Tekeningen\\BT\\0000_BT-BB-022.dwg")
(2024 3 5 15 12 31 56 0)
_$ (dos_filedate "H:\\0000\\0000\\Tekeningen\\BT\\0000_BT-BB-022A.dwg")
(("0000_BT-BB-022A.dwg" . 2.02404e+07))
_$

 

Does anyone know a working alternative for dos_filedate to obtain the date of an opened drawing?

0 Likes
1,825 Views
25 Replies
Replies (25)
Message 21 of 26

HE-MJJ
Advocate
Advocate

When I check now, the results for both dos_filedate and dos-filedate are te same:

 

; form dos_filedate loaded 
_$
_1_$

(("0000_BT-BB-022.dwg" . 2.02403e+07))
_1_$

(("0000_BT-BB-022A.dwg" . 2.02404e+07))
_1_$
_$

; form dos-filedate loaded
_$
_1_$

(("0000_BT-BB-022.DWG" . 2.02403e+07))
_1_$

(("0000_BT-BB-022A.DWG" . 2.02404e+07))
_1_$
_$

 

Then why isn't the date and time displayed the same?

0 Likes
Message 22 of 26

EnM4st3r
Advocate
Advocate

@HE-MJJ wrote:

I seem to be almost there...

 

This is my replacement for dos_filedate so far:

 


for the first part of your if you could just go like this

 

  (if (setq fnm-d (vl-file-systime fnm))
    (setq fnm-d-j (apply 'ctoj (reverse (cddr (reverse fnm-d)))))
  )

and put together you could go like this, but dont know what dos-splitpath does:

(defun dos-filedate (fnm / fnm-d fnm-d-j)
  (setq fnm-d (vl-file-systime fnm))
  (cond
    (fnm-d (setq fnm-d-j (apply 'ctoj (reverse (cddr (reverse fnm-d))))))
    ((= (strcase (strcat (getvar "dwgprefix") (getvar "dwgname"))) (strcase fnm))
     (setq fnm-d-j (getvar "tdupdate"))
     )
  )
  (if fnm-d-j
    (list
      (cons (strcat (nth 2 (dos-splitpath fnm)) (nth 3 (dos-splitpath fnm)))
            fnm-d-j
      )
    )
    fnm
  )
)

 

 

0 Likes
Message 23 of 26

HE-MJJ
Advocate
Advocate

This is my code so far: It replaces the Doslib function.

 

(defun dos-filedate (fnm / fnm-d fnm-d-j )
(if (setq fnm-d (vl-file-systime fnm))
(progn
(setq fnm-d-j (jtod (dtoj (atoi (strcat (rtos (nth 0 fnm-d) 2 0) (strnr (rtos (nth 1 fnm-d) 2 0) 2) (strnr (rtos (nth 3 fnm-d) 2 0) 2) "." (strnr (rtos (nth 4 fnm-d) 2 0) 2) (strnr (rtos (nth 5 fnm-d) 2 0) 2)(strnr (rtos (nth 6 fnm-d) 2 0) 2)))))) ; Check: (rtos (jtod fnm-d-j) 2 6)
(setq fnm (list (cons (strcat (nth 2 (dos-splitpath fnm)) (nth 3 (dos-splitpath fnm))) fnm-d-j)))
)
(if (= (strcase (strcat (getvar "dwgprefix") (getvar "dwgname"))) (strcase fnm)) ; Bij dit geopende bestand
(progn
(setq fnm-d-j (jtod (getvar "tdupdate"))) ; Check: (rtos (jtod fnm-d-j) 2 6)
(setq fnm (list (cons (strcat (nth 2 (dos-splitpath fnm)) (nth 3 (dos-splitpath fnm))) fnm-d-j)))
)
)
)
fnm
)

 

What I don't get is why the time isn't displayed for one of the drawings that use the same dos-filedate function.

0 Likes
Message 24 of 26

HE-MJJ
Advocate
Advocate

I ran into another issue:

 

(dos_filedate "H:\\0000\\0000\\Tekeningen\\BT") results in (("BT" . 2.02406e+07))

 

But

 

(vl-file-systime "H:\\0000\\0000\\Tekeningen\\BT") results in nil

How (under AutoCAD LT) can I obtain the date of a folder?

 

 

0 Likes
Message 25 of 26

HE-MJJ
Advocate
Advocate

I don't get it why (with my latest code) the date is obtained but hours and minutes do not seem to be obtained from the file.

0 Likes
Message 26 of 26

EnM4st3r
Advocate
Advocate
have you tried my code from message 22?
0 Likes