zoukankan      html  css  js  c++  java
  • 遍历目录树,清理编译目录

    下面的代码将当前目录下所有子目录里面的dll, pdb, obj和lib文件全部删除。

    文件名clean.lsp

    ;; remove *.lib, *.dll, *.pdb and *.obj in current folder
    ;; then handle sub folders
    (define (clean-folder dir-path)
      (println "enter " dir-path)
      (let (fs (directory dir-path "\.dll|\.pdb|\.obj|\.lib"))
        (dolist (af fs)
    	    (begin
    	      (println (append "remove file: " af))
    	      (delete-file (append dir-path "\" af))
    	      )
    	    ))
      (let (files (directory dir-path {^[a-z]}))
        (begin
          (dolist (f files)
    	      (let (cf (append dir-path "\" f))
    		(if (directory? cf)
    		    (clean-folder cf))))
          )))
    
    (clean-folder (real-path) )
    
    (exit)
    


    主要当心函数directory返回的虽然是当前目录的子文件,但是只有文件名,路径还要自己拼接。我就在这个地方没有注意,卡了一小时。

  • 相关阅读:
    for循环
    3.9 作业
    while循环
    深浅拷贝
    条件与判断
    可变与不可变
    与用户交互与运算符
    垃圾回收机制
    【AC自动机】文本生成器
    【AC自动机】最短母串
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3263246.html
Copyright © 2011-2022 走看看