Archive: Locate plugin


Locate plugin
Features:
1. Search for directories or empty directories and/or files
    -search with wildcard
    -search with extensions filter (include/exclude)
    -search with times filter
    -search with size filter
    -search with attributes filter
    -sort files and/or directories by name, type, size, date (with reverse or not)
    -output first files or directories
    -search with subdirectories or not
    -search with banner support
    -return path\name
    -return path
    -return name
    -return size of file
    -return date of file or directory
    -return attributes of file or directory
2. Find the size of a file, files wildcard or directory (locate::GetSize)
3. Find the sum of the files, directories and subdirectories (locate::GetSize)
4. Remove empty directories and/or subdirectories (locate::RMDirEmpty)

This plugin is the replacement for Locate and GetSize functions.


"Locate" plugin v1.0


Changes:
-Option /X and /-X - Separated by "|" instead of "," (locate::Open)
-New: option /P - Additional paths to "[Path]" (locate::Open)
-New: option /-PF - Don't locate in these paths (locate::Open)
-New: option /-PN - Don't locate in these directories (locate::Open)


"Locate" plugin v1.1


Changes:
-New: options /N and /-N - names filter (locate::Open)
-Readme improvement


"Locate" plugin v1.2


Does anyone have any example ModernUI code that uses this locate plugin?

I want to locate several files, and present the user with a way of selecing one of them.

How would I go about doing this?


Here you go. Script also using Takhir's nxs plugin


Perfect. Thanks.


Fixed: Case sensitive sort of files and directories (if used sort by "NAME" or "TYPE"). Now case insensitive.
Fixed: Accepted only uppercased sort type "NAME|TYPE|SIZE|DATE". Now case insensitive.


"Locate" plugin v1.3


Fixed: CRT function "tolower" in StrFunc.h didn't return correct national character. "tolower", ("islower", "setlocale" ...) replaced with "CharLower" (user32.dll).


"Locate" plugin v1.4


Changed: Now plugin is msvcrt.dll independed -> work on Win95 (thanks kichik)
Updated: "ConvFunc.h" to v1.3


"Locate" plugin v1.5


Changed: Removed option "/P=", now plugin can accept multi-path in first parameter
Updated: "ConvFunc.h" to v1.5
Updated: "StrFunc.h" to v1.6
Changed: Now plugin used header "Locate.nsh" for custom user variables and
              better compile errors check.

Update from previous versions:
         - Insert line in script:
            !include "Locate.nsh"
         - Replace:
            locate::Open -> ${locate::Open} ...
         - Replace:
            .r0 -> $0, .r1 -> $1 ... .R0 -> $R0, .R1 -> $R1 ...

"Locate" plugin v1.6


Fixed: ignore files/directories names which began with "."
Fixed: error, if file had more then 16 characters extension
Fixed: "/SF=DATE" <=> "/-SF=DATE"
Updated: "StrFunc.h" to v1.7
Updated: "StackFunc.h" to v1.9
Updated: "ConvFunc.h" to v1.7
Changed: Now if files has same date or size they sorted by name
Added: handles for search

"Locate" plugin v1.7


Hi instructor,

How do I use this syntax

${locate::Find} "[handle]" $var1 $var2 $var3 $var4 $var5 $var6

1. I need to find the directory or file exist in C:\Program Files\
2. I need it to change the InstallDIR or setoutpath to the found dir or file in it.

could u create a function for me to perform the task.


Fixed: locate::Open failed to open paths ended with backslash
Updated: "StrFunc.h" to v1.9
Updated: "StackFunc.h" to v2.0
Updated: "ConvFunc.h" to v2.0


"Locate" plugin v1.8


Hi, many of our users are having problems when NSIS uses locate plugin inside windows 7, mainly because msvcr71.dll is natively missing. Can this be fixed (removing this dependency)? Thanks.


zeeh3
You are using self-rebuilded dll? You can check with "Dependency Walker" that plugin linked only to kernel32.dll and user32.dll.


Sorry, there was a mistake... my bad :)


Hi dear Instructor.
I have a problem during using 'locate' with Windows7 32bit

My code is following:
${locate::Open} "$0" "/F=0 /G=0" $0
StrCmp $0 0 0 loop
MessageBox MB_OK "error" IDOK close

loop:
${locate::Find} $0 $1 $2 $3 $4 $5 $6
StrCmp $1 "" close 0

IfFileExists "$1\setup.exe" 0 loop
IfFileExists "$1\config.ini" 0 loop
; do smth
goto loop

close:
${locate::Close} $0 ; at this point application going to hang up
${locate::Unload}


endless loop
Hi Instructor,

I am attempting to cycle through all subdirectories in My Documents. I have hidden directories, the first one Locate comes across is "$AVG" (hidden, readonly). This subdirectory has one subdirectory ($AVG/$CHJW) which contains four files (acgch??.dat).

Following is my open command:
${locate::Open} "$DOCUMENTS" "/F=1 /D=0 /M=*-temp-*.ppp|*Recovered*.ppp /A=-HIDDEN /B=1" $0

The find command seems to find an "endless" number of empty paths\files in the $AVG/$CHJW directory. Adding /-PN=$$AVG stops this behavour but I need this script to run on anyones computer.

Any assistance appreciated!


ivansobaka
Make sure you don't change $0 variable in "; do smth"

dean.g
I'm out of the active NSIS developing, but you can pack this folder and send me on email I will try to reproduce the bug.


I dont use $0 variable in "; do smth"
But I've changed following string

${locate::Close} $0

to

${locate::Close} $R1

Now it works right,
thank you very much


loop
Hi Instructor,

If you need more information please let me know.

Cheers!
Dean


loop
Hi Instructor,

Please find attached.


I'm unable to open .odt files. Lets go the other way. Try to locate in "$CHJW"

${locate::Open} "$DOCUMENTS\....\$$CHJW" 
If it hang, try to remove by one file. If it not hang try to locate in "$AVG"
${locate::Open} "$DOCUMENTS\....\$$AVG" 
It simply can be file system error, like bad clusters on HDD etc.

loop
Hi Instructor,

Here is contents of .odt file (open office text file). I was just showing you the directory structor.

Cheers!


Added: full unicode support on NSIS Unicode.

Locate plugin v2.0


Doesn't Locate All Files
For some reason this plugin cannot locate files such as

c:\.Rhistory

Is there some work-around?


mlf176f2
Is not reproduced.

FILE:"c:\IO.SYS" [110080 b] [Created: 08.06.2000 17:00:00] [-a--]
FILE:"c:\.Rhistory" [0 b] [Created: 31.10.2011 19:57:00] [-a--]
FILE:"c:\ntldr" [251152 b] [Created: 13.04.2008 18:02:06] [rahs]

Locate crashes
My installer crashes when I run locate. It always crashes when it hits a particular folder (c:\Program Files (x86)\Oracle\). Runniny on windows 7.

${locate::Open} "C:\" `/F=1 /D=0 /X=exe /-PN="Oracle" /-PF="$WINDIR\System|$WINDIR\System32|$WINDIR\Help" /N=pg_dump.exe /B=1` $0
${locate::Find} $0 $1 $2 $3 $4 $5 $6
StrCpy $backup $0

If it is reproducible how about running it through a debugger. If you are up for installing Visual Studio 2010 Express and the Windows 7 SDK then I will explain how.

Stu


ok thanks. i'll get back to you if i get that installed.
i'm looking at an another approach looking up exe path through the registry.


Hi,
I have some troubles with ${locate::Open}. I use parametr /-PF=${UpgradeExcludeDirectories} to excluding but my string of excluded files is too long and has been truncated.
I found two possible reasons:
1, I found magic constant :) in source code NSIS_MAX_STRLEN. Can you create bigger buffer please?
2, add parameter which will be able to define excluded files as relative path
Have you any idea or is exist any way how can i use relative paths for excluded files?

Many thanks guys