CnPack Forum


 
Subject: 对临时文件清理有点意见
niaoge
灌水司司长
Rank: 6Rank: 6



UID 9910
Digest Posts 0
Credits 438
Posts 143
点点分 438
Reading Access 10
Registered 2007-4-8
Status Offline
Post at 2007-8-23 15:26  Profile | Blog | P.M. 
对临时文件清理有点意见

刚用cw文件清理时,有点意见,
cw能清理的文件类型多,但不代表多就好
比如刚才,我的第三方控件都方在一个文件夹下,本来想清掉dcu和一些~类型的文件,把不要的去掉,没想到拖动清理类型的滚动条
也没有注意到滚动条后面的(cw默认是选中的),结果不小心把.obj清掉了,完了,有要一个一个地加,obj文件
其实有很多第三方控件带.obj文件,所以.obj肯定不能放在清理选项中,就如不能把.pas,.dfm文件放在清理选项中
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6758
Posts 3555
点点分 6758
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2007-8-23 17:45  Profile | Blog | P.M. 
有些道理,不过obj也可能和dcu一样是编译生成的临时文件,这个确实不好区分。
要不吧obj文件的选项提前显示,并且默认不勾它吧。
Top
gz_runwe
灌水科科长
Rank: 3Rank: 3



UID 12086
Digest Posts 0
Credits 108
Posts 47
点点分 108
Reading Access 10
Registered 2007-4-27
Status Offline
Post at 2007-8-23 22:44  Profile | Blog | P.M. 
可以查找是否有同名的Pas或CPP文件,如果有源文件,obj文件当然可以删除,否则是否删除,通过CheckBox开关控制,默认不删除
Top
gz_runwe
灌水科科长
Rank: 3Rank: 3



UID 12086
Digest Posts 0
Credits 108
Posts 47
点点分 108
Reading Access 10
Registered 2007-4-27
Status Offline
Post at 2007-8-23 22:46  Profile | Blog | P.M. 
当然,以上规则,对dcu应该也适用,这样,就不能简单地删除所有*.dcu和*.obj了,而应该循环*.pas或*.cpp,删除其他文件
Top
yj_yulin
新警察
Rank: 1



UID 20352
Digest Posts 0
Credits 10
Posts 5
点点分 10
Reading Access 10
Registered 2007-7-17
Status Offline
Post at 2007-8-25 12:13  Profile | Blog | P.M. 
同意gz_runwe

下面是我用的python脚本,

import os

def remove_file(file_name):
    try:
      os.remove(file_name)
      print '----------delete file:',file_name
    except:
      pass
  

   

for the_dir,sub_dir,file_list in os.walk('.'):
    print '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
    print '>>>cd directory:',the_dir
    for file_name in file_list:
        print 'check file:',file_name
        
        if file_name.find('.~')>0 or file_name.find('.ddp')>0 or \
           file_name.find('.bak')>0 or file_name.find('.map')>0:
               remove_file(the_dir+os.sep+file_name)
               continue
           
        if file_name.find('.obj')>0: #remove when there has source file
            if os.path.exists(the_dir+os.sep+file_name.replace('.obj','.cpp')):
                remove_file(the_dir+os.sep+file_name)
                continue
            
        if file_name.find('.obj')>0: #remove when there has source file
            if os.path.exists(the_dir+os.sep+file_name.replace('.obj','.cxx')):
                remove_file(the_dir+os.sep+file_name)
                continue
               
        if file_name.find('.obj')>0: #remove when there has source file
            if os.path.exists(the_dir+os.sep+file_name.replace('.obj','.c')):
                remove_file(the_dir+os.sep+file_name)
                continue
               
        if file_name.find('.dcu')>0: #remove when there has source file
            if os.path.exists(the_dir+os.sep+file_name.replace('.dcu','.pas')):
                remove_file(the_dir+os.sep+file_name)
                continue
               


              
              
              

Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6758
Posts 3555
点点分 6758
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2007-8-26 16:13  Profile | Blog | P.M. 
有些道理。不过对于专门设置了output路径的工程来说就有点不适应了。像CW的dcu都放dcu目录下,如果照同一目录下没相应源文件就不删除的规矩来的话,这个dcu就得不到机会清理了。
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6758
Posts 3555
点点分 6758
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2007-8-29 15:54  Profile | Blog | P.M. 
代码改过了,加了个checkbox,默认是不check的,也就是默认全删dcu/obj,第一次用需要手工勾选。
烦请等待unstable版本出来后帮我们验证验证。
Top
gz_runwe
灌水科科长
Rank: 3Rank: 3



UID 12086
Digest Posts 0
Credits 108
Posts 47
点点分 108
Reading Access 10
Registered 2007-4-27
Status Offline
Post at 2007-8-30 00:14  Profile | Blog | P.M. 
谢谢老大啊

Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6758
Posts 3555
点点分 6758
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2007-9-20 01:00  Profile | Blog | P.M. 
332的unstable版本增加了此复选框,烦请楼上各位验证。
http://www.cnpack.org/downbuilds.php?lang=zh-cn
Top
 




All times are GMT++8, the time now is 2024-4-26 06:54

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.009043 second(s), 9 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP