Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 7th April 2005, 05:39   #1
Sashka
Guest
 
Posts: n/a
CreateDirectory does not set error flag?

NSIS version I am using is the latest official release -- NSIS 2.06

Here are the two code samples. First one does not work, so I had to revert to the second one, which does what I want. By not working I mean that it obviously does not create the directory (which has an illegal character '?'), but also it does not display the message box, as it should.

1)
...
StrCpy $TMP_DIR "C:\lalala?"
ClearErrors
CreateDirectory "$TMP_DIR"
IfErrors 0 +3
MessageBox MB_OK "Cannot create directory '$TMP_DIR'"
Abort
...

2)
...
StrCpy $TMP_DIR "C:\lalala?"
ClearErrors
CreateDirectory "$TMP_DIR"
IfFileExists "$TMP_DIR\*.*" +3
MessageBox MB_OK "Cannot create directory '$TMP_DIR'"
Abort
...


Another relevant matter. Are the calls 'IfErrors' and 'GetErrorLevels' related? Would it be correct to say that 'IfErrors' checks whether there is any error at all, whereas 'GetErrorLevel $var' shows the actual error code value?
  Reply With Quote
Old 7th April 2005, 06:08   #2
Sashka
Guest
 
Posts: n/a
Sorry! My previous message is slightly misleading... In fact, I know what the problem is :-). Illegal characters for the dir/file name seem to simply get ignored! So when I tried to create a folder "lalala?", it actually translated it as "lalala", ignoring the '?'.

Another interesting thing totally relevant to the previous paragraph. If you put an illegal character in the path input box on the directory page, this character simply gets ignored!

Isn't all this a bit improper :-)? I think it would be much better for the script writer to handle such an error rather than implement some questionable :-) default behaviour...
  Reply With Quote
Old 7th April 2005, 11:06   #3
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
I think it would be a very bad idea for it not to be automatic.
We'd have to parse all our CreateDirectory, SetOutPath etc strings for invalid characters, and apart from adding to the overhead it'd increase the script size as well.

-Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 7th April 2005, 11:32   #4
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,220
BTW this happens not only with ? and * (*.ns?), but with : as well.
Takhir is offline   Reply With Quote
Old 7th April 2005, 11:47   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
You can't have these in file names:
\ / : * ? " < > |

-Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 7th April 2005, 15:14   #6
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
GetErrorLevel is not realted to IfErrors. See section 2 of appendix D.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 8th April 2005, 00:45   #7
Sashka
Guest
 
Posts: n/a
AfrowUK, so let's say you are creating a directory in a certain file system via a UI or a command line. Would you like it if instead of telling you that the directory with the name you specified is invalid, it would actually create a directory with a different name from what you intended, chopping some characters it does not like and so on? This does not sound very attractive to me personally. I am just trying to reason...
  Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump