Jump to content

Question about: vl-filename-mktemp


EnM4st3r

Recommended Posts

Hi, I want to create a temporary dcl file using vl-filename-mktemp.

The Question is, does that function leave behind a file if I dont delete it within my lisp?

While testing i ran it a few time without deleting it afterwards, so idk if i have a load of dcl files on my drive now..

If it does leave a file behind, any ideas where that files might be located?

Link to comment
Share on other sites

Unless you tell it to be deleted it will remain. If you delete the file via LISP and the user cancels the routine before that delete line then the temporary files will remain of course (suppose you can delete them in error trapping if you want).

 

I'll tend to specify explicitly which folder to save the dcl file to (windows temporary folder, which you -should- be able to clear out whenever you want without thinking...should....). If you don't specify a DCL file name one will be assigned so I will also tend to specify a unique filename for each DCL box I want, each time it is created it will over write pervious renditions of it. If the user cancels the routine and a file name was assigned then it is possible to have a lot of DCL files in the temporary folder, specify the file name and you should only have one... and then you don't need to worry so much about deleting the file

 

 

(OK it is lazy programming to leave stuff behind in the temp folder)

 

Link to comment
Share on other sites

Thank you, found it in C:\Users\user\AppData\Local\Temp
there's also a lot of other files there..

Edited by EnM4st3r
Link to comment
Share on other sites

I set my temp file to d:\acadtemp much shorter and easier to find.

 

Re temp files SV$, AC$hsdkjdsksj DWL1 & dwl2 to mention a few. 

 

The Vlmktmp are meant to be auto removed on closing CAD.

 

Anyway here is cleanup.lsp, you may be horrified how much junk you have in that temp directory.Multi toggles.lsp save multi toggles to a support path as its auto loaded.

cleanup temp.lsp

 

image.png.7339f1bcf72a734bc7036c452fd625de.png

Edited by BIGAL
  • Like 1
Link to comment
Share on other sites

Thanks @BIGAL, that cleanup lisp is nice.

Also yes, there is much Junk in that temp directory.. 
Cleaned it last Week from around 30gb and now there is around 14gb again. So it fills quite fast to that amount.
 

Maybe a good idea to clean it completely once every few months. 

Link to comment
Share on other sites

Let me know if extra file types need to be added. Yes were I worked the guys never cleaned up may wonder why disk is full. I will see if can add how much disk retrieved.

Edited by BIGAL
Link to comment
Share on other sites

10 hours ago, BIGAL said:

I set my temp file to d:\acadtemp much shorter and easier to find.

 

Re temp files SV$, AC$hsdkjdsksj DWL1 & dwl2 to mention a few. 

 

The Vlmktmp are meant to be auto removed on closing CAD.

 

Anyway here is cleanup.lsp, you may be horrified how much junk you have in that temp directory.Multi toggles.lsp save multi toggles to a support path as its auto loaded.

cleanup temp.lsp 2 kB · 5 downloads

 

image.png.7339f1bcf72a734bc7036c452fd625de.png

 

Nice idea.

I tried to add a filetype, but during that process I made a more compact version.

It is using LM:listbox found at https://www.lee-mac.com/listbox.html

 

; clean up temp directory..
(defun cleanuptemp ( / *files* pre types ans val)
  (setq *files* (vla-get-files (vla-get-preferences (vlax-get-Acad-object))))
  (setq pre (vla-get-TempFilePath *files*))
  (mapcar 'princ (list "\n " (chr 149) " Your temp directory is: " pre))

  (setq types
    (mapcar
      (function (lambda (typ / files)
        (setq files (vl-directory-files pre (car typ)))
        (list (strcat (if (= files nil) "0" (rtos (length files) 2 0)) " " (cadr typ)) files)
      ))
      '(
        ("*.BAK"     "BAK's")
        ("*.sv$"     "SV$'s")
        ("*.dwl*"    "DWL's")
        ("*.AC$"     "AC$'s")
        ("*.log"     "Logfile's")
        ("*.dcl"     "DCL's")
        ("*.txt"     "TXT's")
        ("*.scr"     "SCR's")
        ("*.dmp"     "DMP's")
      )
    )
  )

  (if (setq ans (LM:listbox "Pick to delete" (mapcar 'car types) 3))
    (foreach val ans
      (foreach filename (cadr (nth val types))
        (if (vl-file-delete (strcat pre filename))
          (mapcar 'princ (list "\n " (chr 149) " Deleted: " filename))
        )
      )
    )
  )
  (princ)
)
(cleanuptemp)

 

Edited by dexus
Link to comment
Share on other sites

Yes can be done as list box, a suggestion.

 

)

  (if (setq ans (LM:listbox "Pick to delete" (mapcar 'car types) 3))

)
(if (not LM:listbox)(load "leemaclistbox.lsp"))
  (if (setq ans (LM:listbox "Pick to delete" (mapcar 'car types) 3))

 

Will try out (vl-file-size filename) so should display how much deleted.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...