Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Copying Files from CD (http://forums.winamp.com/showthread.php?t=268369)

compmaniac 25th March 2007 23:20

Copying Files from CD
 
In NSIS, is there any way to get the drive letter of a CD by searching for its CD name, and then access the files on the CD?

Would I use this?

http://nsis.sourceforge.net/CDRom_plug-in

If so, what commands would I use to get the drive letter of the CD whose name is "Bob_1"?

How would I copy files over from that drive letter to the $INSTDIR?

Thanks.

Red Wine 26th March 2007 00:11

http://nsis.sourceforge.net/Docs/AppendixE.html#E.1.5

compmaniac 26th March 2007 20:31

Sorry, Red Wine, but I don't think that it talks about searching for the name of the CD. It only tells me how to search for a type of media storage device, and drive letter.

Could you tell me how to find the drive letter of a CD by entering the NAME of the CD I'm searching for?

Many thanks!

Could you also show me how to implement it directly into an installation code file?

Red Wine 26th March 2007 22:02

GetDrives has the option to find CD drives only and returns the corresponding drive letter for each drive.
I think instead of volume name you could add a file on the root of the media e.g. cdid and look for this file, e.g.
code:
Section
${GetDrives} "CDROM" "Example1"
CopyFiles "$R0\my_file.ext" "$INSTDIR\my_file.ext"
SectionEnd

Function Example1
MessageBox MB_OK "$9 ($8 Drive)"
IfFileExists "$9\cdid" 0 next
StrCpy $R0 "$9" ;$R0 contains the drive you're looking
StrCpy $0 "StopGetDrives"
next:
Push $0
FunctionEnd


compmaniac 26th March 2007 22:20

Sorry, but how would I replace IfFileExists "$9\cdid" with multiple files? (so I can make the search more accurate)

I tried &&, but it doesn't work.

Sorry, I'm kind of new to NSIS.

Thanks.

Red Wine 26th March 2007 22:27

You just need to add a unique file on media root that identifies the cd, that's all, just create an empty text file and rename it as cdid and you're done.
Multiple IfFileExists could be easily done with logiclib e.g.
${If} {FileExists} "file1.ext"
${AndIf} {FileExists} "file2.ext"
${AndIf} {FileExists} "file3.ext"
........

compmaniac 26th March 2007 22:37

I did this:

Function Example1
MessageBox MB_OK "$9 ($8 Drive)"
${If} {FileExists} "$9\file1.exe"
${AndIf} {FileExists} "$9\file2.exe" 0 next
StrCpy $R0 "$9" ;$R0 contains the drive you're looking
StrCpy $0 "StopGetDrives"
next:
Push $0
FunctionEnd

(And I also included !include "LogicLib.nsh")

It gave me this:

Function: "Example1"
MessageBox: 0: "$9 ($8 Drive)"
!insertmacro: _If
!insertmacro: macro "_If" requires 4 parameter(s), passed 3!

And then aborted.

Red Wine 26th March 2007 22:40

Gosh! did you first examine the included logiclib example?
code:
Function Example1
MessageBox MB_OK "$9 ($8 Drive)"
${If} ${FileExists} "$9\file1.exe"
${AndIf} ${FileExists} "$9\file2.exe"
StrCpy $R0 "$9" ;$R0 contains the drive you're looking
StrCpy $0 "StopGetDrives"
${EndIf}
Push $0
FunctionEnd


compmaniac 26th March 2007 22:42

Thanks.

But I had to put a dollar sign in front of "file exists"

Red Wine 26th March 2007 22:51

that's true, didn't see my typo.

compmaniac 26th March 2007 23:25

No problem. Thanks for your help.


All times are GMT. The time now is 05:30.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.