Archive: Folder Creation.. what am i missing


Folder Creation.. what am i missing
Hi List.
I am slightly baffled with when an installer creates folders and when it doesn't!
Given the script below (note <path> in place of longer path.

SetOutPath "$INSTDIR\workspace\projects\"
file /r "<path>projects\Drafting1\1.txt"
file /r "<path>projects\Drafting1\Dgnlib\1.txt"
file /r "<path>projects\Drafting1\Data\1.txt"
file /r "<path>Drafting1projects\Cell\1.txt"

when the installer is run, the folder drafting1 is not created even though it contains files but subsequent folders are, eg cell, data, dgnlib.

Like many things with nsis, i am finding this behavior slightly cryptic.

Can somebody please explain the above behaviour.
r,
vsleepy


Try removing the end back-stroke from the SetOutPath call.

-Stu


The /r switch tells NSIS to search for the file in all of the subdirectories. If a file is included from a subdirectory, that subdirectory will also be created on $OUTDIR. But if it's in the root lookup directory, that root directory will not be created.


Unfortunatly the behaviour is very inconsistant.
eg:
SetOutPath "outdirectory"
file /r path1\path2\outdirectory\explicit.txt
file /r path1\path2\outdirectory\path3\explicit2.txt
this example will _not_ create the folder path3, even though path3\explicit2.txt is a valid filter (because the file exists)

but this will:
SetOutPath "outdirectory"
file /r path1\path2\outdirectory\*.txt
file /r path1\path2\outdirectory\path3\*.txt

any hints? I have been going crazy over this!
r
vsleepy


the first example does not create a subdir, because you mix up input and output directory. you need to create an output directory using the SetOutPath command.

the reason why the second example creates the subdir is the first file command (file /r "path1\path2\outdirectory\*.txt") as you are using the /r trigger. the second line is unnecessary, as you already copies all .txt files recursively (=with subdirs).


sorry kichink,
what you said just clicked. it searched the directorys recursivly for the file, then includes it.
so i should do something like:
file /r path1\path2\outdirectory\explicit.txt
file /r path1\path2\outdirectory\explicit2.txt

and because explicit2 is not in the search path, then the sub directory will be created?...? was it really designed this way?!

what happens if if explicit2 exists in many sub directorys?

btw the real issue i guess is not what to install as this can often be determined by using a *.* filter, but rather what to uninstall. the software that i wrote to complile the script now just uses a wild card for inclusion but explicity adds the files that were originally in source dir to the uninstall routine.

a future request of mine would be another switch on the file command to preserve path of explicitly referenced files beyond a given level eg:
file /e 3 dir1\dir2\dir3\dir4\file.ext
would retain the directory path:
<outpath>dir4\file.ext

many thanks,
vsleepy


have a look at this thread


If explicit2 exists in a subdirectory of the search path, it will be extracted to a matching subdirectory of the output path.

If you use File /r <search path>\<matching pattern>, each matched file or folder under <search path> will be extracted to the output path. If the file or folder was found in a subdirectory of the search path, it will be extracted to a matching subdirectory under the output path. If it was found in the search path itself and not under a subdirectory, it will be extracted directly to the output path.