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:
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.
Here's the recursive version, broken into several macros for readability:
Doesn't support too many files (poor ISPP will run out of memory) or large sizes (>2gb), but it should work well for smaller setups.