Archive: Folder Creation


Folder Creation
I just installed NSIS and I'm trying to come to grips with things, I've read a lot of the documentation but there are still many things which are confusing me.
So my first question is regarding creating a folder. If I create a folder under (say) Userdata, and it already exists (for example the user runs the install twice or they have a folder of that name already), what happens? Does the install error out, does the user get a question or what?
What's the best way to prevent this happening, for example, should I be somehow testing for it's existence and taking appropriate action?
Any examples would be more than welcome! :)

many thanks,, and,, "Hello!" nice to meet you all.

Ian


Re: Folder Creation

If I create a folder under (say) Userdata, and it already exists (for example the user runs the install twice or they have a folder of that name already), what happens? Does the install error out, does the user get a question or what?
Answer 1) http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.1.9 or http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.3.3
Answer 2) Why don't you just try it, and see what happens? That would be a lot faster than posting in the forums...

Thank you for your reply.

To answer your question - because no matter what the answer to "what happens if" I would not have known what to do about it so i would still have had to post a question to answer that.

Even after having looked again at the page you reference I'm still unsure of the answer, as I said, I have read the documentation.


i'm new to NSiS too and that's what i figured out from learning by doing:
if your install trys to create a folder that already exists, nothing happens. No error message, nothing. So if you install into a sensitive folder, check if it already exists first or use user confirmations when a file as to be replaced.
if you try to delete a folder that has still files in it, nothing will be deleted and no error comes up.
if you got a folder tree like this:
Root
-- Files
-- Subfolder #1
---- Subfolder #2
------ Files
then you'll gave to create Subfolder #1 first. i know, that's basic knowledge but easy to forget because NSiS does not create Subfolder in not existing folder. With other words: nothing will be done and no error comes up. Same count's for deleting folder. You can't just RMDir the root if there are still files or subfolders in it.
DOS style i say ... a least it what it looks like to me. ^^

Hope i could help a bit or more.


Originally posted by CG!
NSiS does not create Subfolder in not existing folder.
This is not true. Read the documentation.

IB53: What you would have to do to 'try it out yourself', is something like this:

ClearErrors
CreateDirectory "C:\YourPath\YourExistingSubDir"
${If} ${Errors}
MessageBox MB_OK "Error!"
${Else}
MessageBox MB_OK "No error."
${EndIf}

That way, you'll know whether or not NSIS raises the error flag in this situation. You will also see whether or not the user is shown an error/question in this situation. (Spoiler: The user won't see a thing, and no error flag is set.)

Once you know the above two pieces of information, you'll also know that you don't have to do anything to 'prevent it', because nothing goes wrong in the first place.

As you can see, it would've been much quicker to just test this thing out and see what happens.

Creating subfolders in not axisting folders doesn't work for me and it's what i discovered by doing instead of reading.
i'm still new to NSiS, so there's alot to learn left.

Originally posted by MSG
ClearErrors
CreateDirectory "C:\YourPath\YourExistingSubDir"
${If} ${Errors}
MessageBox MB_OK "Error!"
${Else}
MessageBox MB_OK "No error."
${EndIf}
This wasn't the question ... i think.
As far as i understood, he wanted to know if NSiS displays error messages on itself.
So my answer was "No" for the mentioned cases.
That it's possible to catch a possible error is common knowledge and a must have.