使用Inno Setup PreProcessor获取源路径及其子目录的文件和大小 [英] Use Inno Setup PreProcessor to get the files and size of the source path and its subdirs

查看:347
本文介绍了使用Inno Setup PreProcessor获取源路径及其子目录的文件和大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用Inno Setup PreProcessor获取源路径及其子目录的文件和大小吗?



我正在做一个批量编译器,我需要大小在[设置]中自动设置DiskSpanning True或False



只能获取源的大小,



有人可以帮助我吗?






  #define FindHandle 
#define FindResult
#define Mask*。*
#define size 0
#define allfiles


#sub ProcessFoundFile
#define FileName FindGetFileName(FindHandle)
#if direxists(Filename)&&文件名!= &安培;&安培; Filename!=..
#Define公共遮罩AddBackSlash(文件名)+*。*
#else
#Define Mask*。*
#endif
#define public allfiles allfiles + - + Filename
#define public size size + FileSize(FileName)
#endsub


#for {FindHandle = FindResult = FindFirst(Mask,faDirectory); FindResult; FindResult = FindNext(FindHandle)} ProcessFoundFile
#if FindHandle
; FindClose(FindHandle)
#endif


#IF大小> 2100000000
#DEFINE SpanTrue
#ELSE
#DEFINE SpanFalse
#ENDIF

[安装]
DiskSpanning = {#Span}
InternalCompressLevel = ultra
DiskClusterSize = 2048
CompressionThreads = 2
压缩= lzma2 / ultra64
SolidCompression = no


解决方案

好的,这有点旧,但是我想分享我的解决方案,因为我遇到同样的问题,找到了一些解决方案:

  #define FindHandle 
#define FindResult
# dim InnerMask [65536]
#define InnerMask [0]
#define size 0

#sub ProcessFoundFile
#define InnerFileName FindGetFileName(FindHandle)
#define fileName InnerMask [InnerMaskWorkPosition] + InnerFileName
#if InnerFileName!=。 &安培;&安培; InnerFileName!=..
#if direxists(FileName)
#define Public InnerMask [InnerMaskPosition] FileName +\
#define Public InnerMaskPosition InnerMaskPosition + 1
#else
#define public size size + FileSize(FileName)
#endif
#endif
#endsub

#sub ProcessInnerMaskPosition
#for { FindHandle = FindResult = FindFirst(InnerMask [InnerMaskWorkPosition] +*,faAnyFile); FindResult; FindResult = FindNext(FindHandle)} ProcessFoundFile
#if FindHandle
#expr FindClose(FindHandle)
#endif
#endsub

#sub RunSizeScan
#define Public InnerMaskPosition 1
#define Public InnerMaskWorkPosition 0
#expr size = 0
#for {InnerMaskWorkPosition = 0; InnerMaskWorkPosition InnerMaskPosition; InnerMaskWorkPosition ++} ProcessInnerMaskPosition
#undef公共InnerMaskPosition
#undef公共InnerMaskWorkPosition
#endsub

#expr InnerMask [0] =你要命名-the-size-of\
#expr RunSizeScan

#if size> 2100000000
#define SpanTrue
#else
#define SpanFalse
#endif

它的作用是扫描数组InnerMask中给定的目录,而不是。要么 ..。文件被添加到已经计算的大小,目录被添加到数组InnerMask。注意:由于数组的限制设置为65536,所以不应该有超过此数量的文件夹嵌套在您扫描的目录中。否则,您可以尝试重新使用第一个已处理的阵列插槽或使用多个阵列。


Can I use Inno Setup PreProcessor to get the files and size of the source path and its subdirs?,

I am doing a Batch Compiler and I need the size to auto-set in [Setup] DiskSpanning True or False

Only can get the size of source,

Somebody can help me?


#define FindHandle
#define FindResult
#define Mask "*.*"
#define size 0
#define allfiles ""


#sub ProcessFoundFile
 #define FileName FindGetFileName(FindHandle)
  #if direxists(Filename) && Filename!="." && Filename!=".."
   #Define Public Mask AddBackSlash(Filename)+"*.*"  
  #else
   #Define Mask "*.*"
  #endif
 #define public allfiles allfiles + " - " +Filename
 #define public size size + FileSize(FileName)  
#endsub


#for {FindHandle = FindResult = FindFirst(Mask, faDirectory); FindResult; FindResult = FindNext(FindHandle)} ProcessFoundFile
#if FindHandle
;  FindClose(FindHandle)
#endif


#IF Size > 2100000000
#DEFINE Span "True"
#ELSE
#DEFINE Span "False"
#ENDIF

[Setup]
DiskSpanning={#Span}
InternalCompressLevel=ultra
DiskClusterSize=2048
CompressionThreads=2
Compression=lzma2/ultra64
SolidCompression=no

解决方案

Ok, so this is a bit old but I want to share my solution though because I came across the same problem and found some kind of a solution:

#define FindHandle
#define FindResult 
#dim InnerMask[65536]
#define InnerMask[0] ""
#define size 0     

#sub ProcessFoundFile
    #define InnerFileName FindGetFileName(FindHandle)
    #define fileName InnerMask[InnerMaskWorkPosition] + InnerFileName
    #if InnerFileName!="." && InnerFileName!=".."
        #if direxists(FileName)
            #define Public InnerMask[InnerMaskPosition] FileName+"\"
            #define Public InnerMaskPosition InnerMaskPosition + 1
        #else
            #define Public size size + FileSize(FileName)
        #endif
    #endif 
#endsub

#sub ProcessInnerMaskPosition 
    #for {FindHandle = FindResult = FindFirst(InnerMask[InnerMaskWorkPosition]+"*", faAnyFile); FindResult; FindResult = FindNext(FindHandle)} ProcessFoundFile
    #if FindHandle
        #expr FindClose(FindHandle)
    #endif
#endsub

#sub RunSizeScan
    #define Public InnerMaskPosition 1
    #define Public InnerMaskWorkPosition 0
    #expr size=0
    #for {InnerMaskWorkPosition = 0; InnerMaskWorkPosition < InnerMaskPosition; InnerMaskWorkPosition++} ProcessInnerMaskPosition
    #undef Public InnerMaskPosition
    #undef Public InnerMaskWorkPosition
#endsub

#expr InnerMask[0]="some-dir-name-you-want-the-size-of\"
#expr RunSizeScan

#if size > 2100000000
    #define Span "True"
#else
    #define Span "False"
#endif

What it does is to scan the given directories in the array "InnerMask" for everything which isn't "." or "..". Files are added to the already calculated size and directories are added to the array "InnerMask". This Process will end once there are no more subdirectories to evaluate.

Note: As the limitation of the array is set to 65536, you should not have more than this amount of folders nested in you scanned directory. Otherwise you could try to reuse the first already processed array slots or work with multiple arrays.

这篇关于使用Inno Setup PreProcessor获取源路径及其子目录的文件和大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆