- NSIS Discussion
- Automatic logging of files?
Archive: Automatic logging of files?
galil
14th April 2003 11:10 UTC
Automatic logging of files?
Here's the story (sorry, it's a bit too long, but I want to be sure that everything's clear):
I use "external" nsis installer: setup.exe and Instdata dir is packed into one with WinRar sfx. During install they're both unpacked to tempdir, and setup.exe copies files from Instdata using CopyFiles. So far so good.
Uninstaller reads filenames from $INSTDIR\files.lst, where files.lst is a text list of all the files that must be removed:
file1.exe
file2.dll
Data\file3.dat
Data\Sound\file4.wav
And so on (~300 entries).
Now the problem is that I make files.lst myself and supply it in Instdata\files.lst. So being lazy (and it's not very comfortable, because the only thing that changes in the package are files in Instdata, and sometimes i'm not the last one who adds files to package) I thought:
"Wouldn't it be cool, if setup.exe on the run scans $EXEDIR\Instdata and automatically generates Instdata\files.lst" or something similar. But I'm not programmer, in truth I have 0 experience in this field. I've tried to write using Findfirst & Findnext, but it didn't work (as if I'm surprised) - wasn't working on subdirs and in the end crashed anyways, so I have no idea whatsoever. :igor:
TIA,
galil
kichik
14th April 2003 17:45 UTC
Example:
Function ScanDir
Exch $2
Push $0
Push $1
FindFirst $0 $1 "$2\*.*"
IfErrors done
loop:
StrCmp $1 "." next
StrCmp $1 ".." next
Push "$2\$1"
Call ScanDir
DetailPrint "$2\$1"
next:
FindNext $0 $1
IfErrors done loop
done:
Pop $1
Pop $0
Pop $2
FunctionEnd
Section "Scan $TEMP"
Push $TEMP
Call ScanDir
SectionEnd
You can easily change this to write to a file instead of printing it.
Removing the full path can also be arranged with so much effort.
galil
16th April 2003 21:25 UTC
Thank you so much for your reply! :up: :)
However I can't get your example script to work :(
When run, it displays only:
E:\TEMP\TEMP
Completed
So I changed -
FindFirst $0 $1 $2*.*
to
FindFirst $0 $1 $2\*.*
- and removed "Call ScanDir" line from function itself.
So now it kinda works, but it has two flaws: lists directory names too (I don't need that, but I guess I could remove those entries by searching for "." in the string) and, most importantly, doesn't scan subdirectories.
So do I got your example wrong or what? :confused:
TIA,
galil
kichik
16th April 2003 21:30 UTC
Try the code again, I have mistakenly used [ php ] which is known to remove slashes. It's now using [ code ] which doesn't remove anything.
galil
17th April 2003 12:29 UTC
Tried it, now it only lists 1 file from temp dir, like:
E:\TEMP\TERRA FIRMA (Lara's Mix).mp3
Completed
When I removed that call to itself:
...
Push "$2\$1"
Call ScanDir; <- why this? I removed it.
DetailPrint "$2\$1"
...
, then it lists all files. But it doesn't scan subdirectories of Temp. :weird:
TIA,
galil
kichik
17th April 2003 12:34 UTC
The exact code, as written in the above post, works perfectly fine. Please try the attachment.
galil
17th April 2003 14:08 UTC
Your compiled exe works fine.
But when I try to compile it myself using the script I attached,
it doesn't work.
I guess I'm missing something again. :(
TIA,
galil
PS: I'm sorry for being so retarded.
kichik
17th April 2003 14:17 UTC
It's the exact same script as mine... What version are you using? If it's a version from CVS get the latest CVS version, if it's a version that's older than b3 get b3, and if it's b3 get latest CVS version.
galil
17th April 2003 14:42 UTC
I'm using b3.
I'll try latest CVS, downloading atm.
galil
17th April 2003 15:34 UTC
Woohoo, it works with CVS! Strange why it didn't with b3 though. Anyway, I'm so excited I gonna run around the office in circles, thank you so much! :up:
Now I only need to change it to my needs. To get rid of that full path part, and I also don't need directory names included in the list. I guess I'll go check the Archive for some examples..
TIA,
galil