Archive: Possibility to ignore files within "File /r option"


Possibility to ignore files within "File /r option"
  Dear Folks -

is there a way to integrate some directives in the compiler-script to exclude folders and/or files which are in the potential path the compiler integrates files?

The reason is that the application I do is in a CVS. So I don't want to go through the whole structure and delete CVS-directories and included files everytime I actualized the working dir...

Thx Mo


Maybe you can create a batch file that removes the CVS data.


So there isn't one (a solution)?

It's not the problem to delete the directories and included files, but copying the whole CVS everytime again.

I have the (application) structure underneath the NSIS-Directory to be able to work with

FILE/r "${NSISDIR}\\path\\to\\my\\raw\\applikation..." 

. So it would be very nice to make CVS/...-dirs "invisible" for the installer. It is anoying to copy the CVS workingdir every time again to ths NSISDIR even for the smallest changes.

The simple deletion is no problem "Search in Explorer; [CTRL]+[A]; [DEL]"

Any further ideas?

Isn't there another possibility to exclude directories within the compilerrun? It would't be very comfortable to list everysingle dir but not the ones to be excluded.

Wouldn't this be an feature worth to be integrated, as possible many others could use it to compile there prog out of CVS?

Mo!


You can have another program create a list of File commands that will exclude CVS directories. You can call this program using !system and then !include its output. This program can even be a simple installer using FindFirst, FindNext and FindClose.

This feature request is already in the feature request list and will hopefully be implemented for version 2.1.


My late answer, sorry :D

Thx for your answer! But I think I do it the oldfashioned way and am going to synchronize manually my CVS-repository. The one downloaded and the one without CVS-dirs (to be compiled) until this version 2.1 is released....

Thx
Mo


I am actually working on a program to do this. Anyone interested in helping out feel free to contact me or post a reply here.


I would be instrested to help, although I'm not sure of how much help I would be. Assuming you are going to use c/c++ cos I'm only learning those languages. :o

Vytautas


Yeh I'll be using C/C++, if you have any design thoughts pass them along. Not doing any actual programming just yet.


Really the biggest question I can think of anyone has any preference for the command line paramters for the program. I'm thinking of something like,

DIRECTORY /r "c:\Program Files\*.*" "Folder1\*.exe,Folder2\*.*"

The first parameter would take the folder to look through, the second would be the list of files/folders to ignore delimited by commas. Wildcards would be allowed for the both the directory to look through of files to install as well as the files/folders to ignore.

In the example above "Folder1" and "Folder2" would be subdirectories under the main inclusion folder of "c:\program files".

There would be an optional command line paramter of "/r" to do a recursive inclusion of files like in the NSIS "File" command.


I've run into a nice problem setting up this program. I can call the program I've made within a script to generate a list of files as follows,

!system "FolderList.exe $\"c:\Temp\*.*$\"

$\"*.exe,*.ico$\""
In this case all the files within the c:\temp folder would be included except for files with the extension exe and ico.

A text file will be created called "FolderList.txt" containg the file list which I want to include like so
!include "FolderList.txt" 
Unfortunately by the time this text file is created makensis is already done! So none of the files actually get included in the final executable. Is there any way to get the compiler to wait until this text file is created?

It should wait. Is it a normal application? Does ExecWait work if you are calling it from an installer (just to test)?


Yes it's a normal console application and yes ExecWait does seem to work when calling it from an installer.


Ok, my mistake Joost. It is working. I was getting confused because it was taking longer for the file to actually appear within Windows explorer. So with that in mind here is the first version,

The program is called FolderList and used within a script as follows,

!system "FolderList.exe $\"c:\Temp\*.*$\" $\"*.exe,*.ico$\""

>!include "FolderList.exe.txt"
Note the quotation marks on the call to "!system" I think this is what messed me up the first few time.

You currently cannot recurse a file structure like you can with the NSIS "File /r" command. I will be adding this soon. Breakdown of the paramters are as follows,

1st paramter - The file/folder of files to include. Wildcards are
allowed.
2nd paramter - List of files to exclude from the inclusion list.
Wildcards are allowed.

Here's an updated version of FolderList. You can now use /r to recurse a folder structure. I have also created two macros which can be used insted of the !system and !include commands.

!macro FOLDER_LIST INCLUDE_DIR EXCLUDE_FILES

!system "FolderList.exe $\"${INCLUDE_DIR}$\" $\"${EXCLUDE_FILES}$\""
!include "FolderList.exe.txt"
>!macroend

>!macro FOLDER_LIST_RECURSIVE INCLUDE_DIR EXCLUDE_FILES
!system "FolderList.exe /r $\"${INCLUDE_DIR} $\" $\"${EXCLUDE_FILES}$\""
!include "FolderList.exe.txt"
>!macroend
>
Some example usages are,

"c:\Temp\*.*" "*.exe,*.com"

>!insertmacro FOLDER_LIST_RECURSIVE "c:\Temp\*.*" "folder1\*.txt,folder2\*.com"
The first example I have explained in previous posts. The second example will include all files in c:\Temp and it's subfolders. It will cut out txt files in c:\Temp\folder1 and com files from c:\Temp\folder2

FolderList can be used in replace of any "File" script command.

A note on how files/folders are ignored. If you choose to recurse a file structure the ignore file list must mirror this structure.

If for example Temp has sub directories of folder1, folder2, etc. and I want to ignore all exe files in both folder1 and folder2 I have to do the following,

FolderList.exe /r "c:\Temp\*.*" "folder1\*.exe,folder2\*.exe"

You cannot ignore all exe files in folder1 and folder2 using one command. You currently have to specify them as separate ignore filters.

I am working on a way to get around this now. Vytautas (or anyone else), if you've got any suggestions I could definitely use them now.

A note from the previous post, this line,

!insertmacro

FOLDER_LIST_RECURSIVE "c:Temp*.*" "folder1*.txt,folder2*.com"
should be
FOLDER_LIST_RECURSIVE "c:Temp*.*" "folder1\\*.txt,folder2\\*.com" 

Forgot to add the backslashes

I think that's because [php ] [/php ] removes them.

!insertmacro FOLDER_LIST_RECURSIVE "c:\Temp\*.*" "folder1\*.txt,folder2\*.com"


-Stu

Dear rsegal -

Thx for your work, I will give it a try, if it fits my needs. You will get the feedback immediatley when integrated and tested...

So long

Chris aka Mo


Yeh, I noticed that after I posted Afrow. I didn't think the php code tags would take that into account.


I have a question on the usage:

What exactly does this program? Does it remove the folders, or does it make them "invisible" for the compiler. If so, where do we have to include the lines you've provided with your examples?

As in my case there are about 15-20 sections, so I get a little confused. Is it possible to include it within a section, and again if yes, how is it placed? All these sections include this *funky* CVS-dirs with the normal device-files. They should not exist in the compiled application...

Thx Mo


I have noticed that if a subdirectory is empty the compiler generates an error, otherwise its a great program.

Vytautas :)


After more testing I found that my previous post was not quite correct. The complier error was generated when it hit the subdirectory name and as it is not a file the error occurs.

Also this program does not seem to take into account the directory structure as it does not modify the $OUTDIR variable thus all of the files are copied into the root directory.

As a sugestion is an inclusion of the posibility to exclude all of thefiles except those that match a certain criteria.

!insertmacro FOLDER_LIST_RECURSIVE "c:\Temp\*.*" "+folder1\*.txt"
This command would exclude all of the files in folder1 except for those with a '*.txt' extention.

Vytautas

PS. Keep up the good work. :cool:

Originally posted by Mosestycoon

What exactly does this program? Does it remove the folders, or does it make them "invisible" for the compiler. If so, where do we have to include the lines you've provided with your examples?

As in my case there are about 15-20 sections, so I get a little confused. Is it possible to include it within a section, and again if yes, how is it placed? All these sections include this *funky* CVS-dirs with the normal device-files. They should not exist in the compiled application...
This program makes the the files/folders that you specify invisible to the compiler. Just take a look at the text file it creates. It's just a bunch of "File" commands. You can include the lines I specified anywhere the "File" command is valid because it's doing the same thing.

I know the CVS dir's your talking about as I've run into the same problem. If you have alot of files/folders to include it will be tedious to ignore each "CVS" named folder within all the folders you are including. This is why I'm working on a way to ignore a file or folder that exists in multiple folders. I mentioned this in a previous post.

To ignore a CVS folder just use
!insertmacro FOLDER_LIST_RECURSIVE "c:\\YourFolder\\*.*" "CVS\\*.*" 
This will ignore the folder c:\YourFolder\CVS and all files/folders within it.

Originally posted by Vytautas

After more testing I found that my previous post was not quite correct. The complier error was generated when it hit the subdirectory name and as it is not a file the error occurs.
That's very bizarre. What is the error you get? Subdirectories should not be a problem at all.
Originally posted by Vytautas

Also this program does not seem to take into account the directory structure as it does not modify the $OUTDIR variable thus all of the files are copied into the root directory.
This is true. The $OUTDIR variable is not modified although this would be the case as well if you were to use the "File" command. It doesn't modify the $OUTDIR variable. My program works the same way. You need to set $OUTDIR before you call my program. I probably should've mentioned that initally, sorry about that.

Originally posted by Vytautas

As a sugestion is an inclusion of the posibility to exclude all of thefiles except those that match a certain criteria.
code:

!insertmacro FOLDER_LIST_RECURSIVE "c:\Temp\*.*" "+folder1\*.txt"

This command would exclude all of the files in folder1 except for those with a '*.txt' extention.
I was thinking of doing what you just said however you could do the same thing in a different way.
!insertmacro FOLDER_LIST_RECURSIVE "c:\\Temp\\folder1\\*.txt" 
Obviously this doesn't include any of the other folders under Temp but it does work. Provided you don't have a large number of folders in the Temp folder that may work for you. Just add the other folders separately. Obviously if it worked the way you're suggesting then all of the other subfolders under "Temp" would work. So there is a benfit to it. I'll put it on my list of features to add.

!insertmacro FOLDER_LIST_RECURSIVE "c:\\Temp\\*.*" "folder1\\*.txt" 
Originally posted by Vytautas

PS. Keep up the good work.
Thanks!:)

The first error only seems to happen when you compile in Win2k as when I tested with Win98 it worked fine but when I tried to compile the same script in Win2k I got an error that said that the file was not found listing the name of the subdirectory.

The second problem is that if you use a single file command to recurse a directory tree it also recreates the whole tree so that the files in the subfolders on the local machine are placed in the same subdirectories on the target machine. However you program produces a list of file commands that copy files from their subdirectories into the $OUTDIR set by the installer before the call but it does not recreate the directory tree. For example: If you have two directories one containing exe files and another containing help files using your program both the exe and help files would end up in the root directory rather that the 'bin' and 'help' directories.

As for the last suggestion I was thinking of a case where the whole program directory could be recursed but one of several directories only needed to copy one type of file. It would make this sort of senario a lot easier to manage.

Vytautas


To ignore a CVS folder just use

PHP:

!insertmacro FOLDER_LIST_RECURSIVE "c:\YourFolder\*.*" "CVS\*.*"



This will ignore the folder c:\YourFolder\CVS and all files/folders within it.
I gave that a try, but it didn't work for me. I included the following lines:

!macro FOLDER_LIST_RECURSIVE INCLUDE_DIR EXCLUDE_FILES
!system "FolderList.exe /r $\"${INCLUDE_DIR} $\" $\"${EXCLUDE_FILES}$\""
!include "FolderList.exe.txt"
!macroend
!insertmacro FOLDER_LIST_RECURSIVE "${NSISDIR}\FILEDIR\*.*" "CVS\*.*"


where ${NSISDIR}\ is of course the directory I administer my project in. The following error occurs at MakeNSISW:

!insertmacro: FOLDER_LIST_RECURSIVE
!system: "FolderList.exe /r "C:\Programme\NSIS\TSW\*.* " "CVS\*.*""
!system: returned 0
!include: "FolderList.exe.txt"
File: "C:\Programme\NSIS\TSW\DATENBANK" -> no files found.
Usage: File [/nonfatal] [/a] ([/r] filespec [...]|/oname=outfile one_file_only)
!include: error in script: "FolderList.exe.txt" on line 1
Error in macro FOLDER_LIST_RECURSIVE on macroline 2


Any idea?

Ah: and of course: Keep on!
:D


The last error Mosestycoon described is the error I get when I try to compile on Win2k.

Vytautas


Originally posted by Vytautas

The second problem is that if you use a single file command to recurse a directory tree it also recreates the whole tree so that the files in the subfolders on the local machine are placed in the same subdirectories on the target machine. However you program produces a list of file commands that copy files from their subdirectories into the $OUTDIR set by the installer before the call but it does not recreate the directory tree. For example: If you have two directories one containing exe files and another containing help files using your program both the exe and help files would end up in the root directory rather that the 'bin' and 'help' directories.
I see what your saying now. Yes you're right I didn't take this into account originally. I recently fixed this problem and will probably post a new version tomorrow.

Ah, ok...
One more info: I have tested it on WinXP. So this is not limited to W2K...


Ok this version should solve the directory recreation issue in the installing folder. Given a folder "c:\temp" that has many subfolders say, folder1, folder2, folder3, ..., folderN these folders will be created in the installtion directory as $OUTDIR\folder1, $OUTDIR\folder2 rather than dumping everything into $OUTDIR as it was doing before.


Dear rsegal -

I gave your latest FolderList a try, but still without success. Ok perhaps I am doing it wrong, so here is what I did:

!macro FOLDER_LIST_RECURSIVE INCLUDE_DIR EXCLUDE_FILES
!system "FolderList.exe /r $\"${INCLUDE_DIR} $\" $\"${EXCLUDE_FILES}$\""
!include "FolderList.exe.txt"
!macroend

!insertmacro FOLDER_LIST_RECURSIVE "${NSISDIR}\TSW\*.*" "CVS\*.*"

(Still the part I've mentioned above)

This time, I get another compilererror:
!insertmacro: FOLDER_LIST_RECURSIVE
!system: "FolderList.exe /r "C:\Programme\NSIS\TSW\*.* " "CVS\*.*""
!system: returned 0
!include: "FolderList.exe.txt"
Push: $OUTDIR
Error: Can't add entry, no section or function is open!
!include: error in script: "FolderList.exe.txt" on line 1
Error in macro FOLDER_LIST_RECURSIVE on macroline 2


If I take a closer look to the generated file FolderList.exe.txt (Line 1-11 which are mentioned to be the faulty line), it is showing the following lines:
Push $OUTDIR
CreateDirectory "$OUTDIR\DB"
SetOutPath "$OUTDIR\DB"
Pop $OUTDIR
Push $OUTDIR
CreateDirectory "$OUTDIR\DB\CVS"
SetOutPath "$OUTDIR\DATENBANK\CVS"
File "C:\Path\to\NSIS\TSW\DB\CVS\Entries"
File "C:\Path\to\NSIS\TSW\DB\CVS\Entries.Extra"
File "C:\Path\to\NSIS\TSW\DB\CVS\Repository"
File "C:\Path\to\NSIS\TSW\DB\CVS\Root"


Any ideas?
Mo

Sounds like you are calling my program outside of a section or function. As it mentioned from your error you cannot call "Push $OUTDIR" outside a section. You also cannot make a call to "File" outside of a section or function.


I not tested this plugin yet, but have "maybe" a simpler way to do these things with some useful NSIS commands... (remembering...)

Quote from Kichik
This program can even be a simple installer using FindFirst, FindNext and FindClose.
Isn't? (Kichik and your really useful tips...)

A new bug in the latest version of your program. It is a little difficult to describe so I will attach directory tree snapshots the dir.txt file contains the source directory and dir1.txt contains the target directory produced by the installer. {NOTE: No files were actually excluded in this script.}

Because the files in your program are sorted in alphabetical order files in the root directories get placed in subdirectories is they come after a folder in the sorting order.

Vytautas :eek:


I have noticed that you include a CreateDirectory command before SetOutPath, this is not needed as SetOutPath creates the path if it does not exist.

Vytautas ;)


Originally posted by deguix
I not tested this plugin yet, but have "maybe" a simpler way to do these things with some useful NSIS commands... (remembering...)

Quote from Kichik
This program can even be a simple installer using FindFirst, FindNext and FindClose.

Isn't? (Kichik and your really useful tips...)
Sure you could probably do the same thing with those script calls. I'm doing it with the same Win32 calls in C++. NSIS is definitely nice but I've been using C/C++ alot longer than I've been working with NSIS. It's what I'm most proficient and comfortable with. That's why I chose it.

Originally posted by Vytautas
I have noticed that you include a CreateDirectory command before SetOutPath, this is not needed as SetOutPath creates the path if it does not exist.
Well therer you are, you learn something everyday.

Originally posted by Vyatautas
Because the files in your program are sorted in alphabetical order files in the root directories get placed in subdirectories is they come after a folder in the sorting order.
I don't recall having that problem however I'll be sure to check it out. Thanks again for the feedback, it helps alot!

Originally posted by rsegal
Sounds like you are calling my program outside of a section or function. As it mentioned from your error you cannot call "Push $OUTDIR" outside a section. You also cannot make a call to "File" outside of a section or function.
Okay, so I have to call it in every section like:
Section "1" sec1
!insertmacro FOLDER_LIST_RECURSIVE "${NSISDIR}\Path\to\Section1\Dir\*.*" "CVS\*.*"
...
SectionEnd

Section "2" Sec2
!insertmacro FOLDER_LIST_RECURSIVE "${NSISDIR}\Path\to\Section2\Dir\*.*" "CVS\*.*"
...
SectionEnd


Is that correct rsegal?
Thx for your great engagement and support :up: (That's why the community lives...)

Mo

Originally posted by Mosestycoon
Okay, so I have to call it in every section like:
Section "1" sec1
!insertmacro FOLDER_LIST_RECURSIVE "${NSISDIR}\Path\to\Section1\Dir\*.*" "CVS\*.*"
...
SectionEnd

Section "2" Sec2
!insertmacro FOLDER_LIST_RECURSIVE "${NSISDIR}\Path\to\Section2\Dir\*.*" "CVS\*.*"
...
SectionEnd


Is that correct rsegal?

Mo
Yep, that's right. You can make both calls in the same section or in separate sections like you've got.

Originally posted by Mosestycoon
Thx for your great engagement and support :up: (That's why the community lives...)
Your welcome