Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Regular expressions for path? (http://forums.winamp.com/showthread.php?t=385195)

Bungkai 20th November 2015 19:51

Regular expressions for path?
 
Been looking through google to try to find something similar. Shows me the NSISpcre plugin. Not particularly against it or anything, but I'm new to NSIS already and if I don't need it I'd prefer not to use it.

I'm basically looking to build an installer for a plugin that would install files into a particular location. The path however, from different versions would vary from computer to computer.
ex. C:\Program Files\[A random program]\[Program Name 2012]\
C:\Program Files\[A random program]\[Program Name 2015]\

How would I go about expressing different version numbers? Same goes for Program Files as there is 32bit version of windows and 64 bit version of windows.

Any help would be greatly appreciated.

LoRd_MuldeR 20th November 2015 23:16

Assuming that the application is installed under a certain fixed path is a bad idea! You could try to search for the application (recursively), using the FindFirst and FindNext functions, but that's still slow and error prone. Instead, most applications will write their location to the registry - under a well-known registry key/value. So, in order to "detect" the install location, you just read the appropriate registry value.

Bungkai 23rd November 2015 20:40

Okay so I've done what you've said with success. I'm able to find the path based off of the registry. My problem now is that a certain file is also year dependent. as in [ApplicationName][year].[fileextension].

I was able to use IfFileExists to find out if say [ApplicationName]20*.lsp (it's an lsp file I'm looking for) to find if a certain path contains that file in the year 2000 to 2099. It's able to do that. My question is now, how do I put this into a variable to use? Putting the asterisk in a strcpy statement, detailprint or a fileopen puts the literal character in there. I need to be able to open any year version basically whether it be a file in the year 2000 or the year 2099

LoRd_MuldeR 23rd November 2015 21:46

If possible somehow, try to detect the exact file name from the registry. Or based on some other available info.

If it's really not possible and you have to search for the file at runtime, use something like:
PHP Code:

FindFirst $$"$INSTDIR\*.foo"
loop:
  
StrCmp $"" done
  DetailPrint 
"Found: $1"
  
FindNext $$1
  
Goto loop
done
:
FindClose $


Bungkai 24th November 2015 16:30

Quote:

Originally Posted by LoRd_MuldeR (Post 3040460)
If possible somehow, try to detect the exact file name from the registry. Or based on some other available info.

If it's really not possible and you have to search for the file at runtime, use something like:
PHP Code:

FindFirst $$"$INSTDIR\*.foo"
loop:
  
StrCmp $"" done
  DetailPrint 
"Found: $1"
  
FindNext $$1
  
Goto loop
done
:
FindClose $



It's possible but I'm unsure if the registry would be the same across all versions of the program.

So I'm trying to open it as soon as I find the file. I know how to read/write with NSIS, but the above code you posted I don't 100% understand. Is this piece of code solely to detect whether or not the file exists in the directory?

I want to be able to find the file, hold it in a variable (I've done up to this part), and then check the variable to see if it fits the regex pattern I stated in the thread and then open if it does match.

I just tried

PHP Code:

Strcmp $"(program)20*.lsp" found notFound 

where $0 holds the correct file name. I think the 2nd part where it compares $0 to a string is where it falls, it most likely takes the * literally instead of what I want it to do.

Bungkai 24th November 2015 17:26

Never mind, I didn't need to do what I just posted. I'm just running loops in my head. Thanks a lot for your help.

LoRd_MuldeR 24th November 2015 17:37

The code above iterates over all files that match the specified template. In the example I used "$INSTDIR\*.foo", so it would iterate over all .foo files in the install directory. But you can use whatever template you deem suitable for your needs...

For details see the NSIS manual:
http://nsis.sourceforge.net/Docs/Cha...html#FindFirst


All times are GMT. The time now is 17:41.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.