Author Topic: [BUG]: "Directory cannot be created" error if directory is present  (Read 5133 times)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
- Create a C project (using the wizard) having the two targets "debug" and "release" enabled
- Close the project
- Create another C project with the very same name, say "yes" to all warnings about "you are
overwriting stuff"...

C::B errors with "The directory cannot be created" - which is true, because the directory already exists.

With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: [BUG]: "Directory cannot be created" error if directory is present
« Reply #1 on: November 15, 2006, 05:52:02 pm »
Ok - it errors in wiz.cpp (scripted wizard plugin) at line 327:
Code
if (!CreateDirRecursively(prjdir))
...continuing search...

Edit: The issue here: CreateDirRecursively gets a directory with a trailing path separator and cannot handle this - "Early out" will not work in that case.

Thomas - I knew it... *g*
« Last Edit: November 15, 2006, 05:55:45 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: [BUG]: "Directory cannot be created" error if directory is present
« Reply #2 on: November 15, 2006, 06:07:35 pm »
Except "early out" is entirely innocent :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: [BUG]: "Directory cannot be created" error if directory is present
« Reply #3 on: November 15, 2006, 06:14:05 pm »
Ah - I see...
3206 - [thomasdenk] - 3 days:
- Corrected return value on "already exists" in CreateDirRecursively() to be consistent with "successfully created".
:-(
That easy??? Dammed!!!

Edit: Wait a second... that's correct! - No you got me confused entirely...?!
« Last Edit: November 15, 2006, 06:18:17 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: [BUG]: "Directory cannot be created" error if directory is present
« Reply #4 on: November 15, 2006, 06:22:16 pm »
I don't get it: Why is early out innocent? The path exists, so wxDirExists should be true, thus: early out. CreateDirRecursively() should return "true" in that case which wouldn't cause the error message of wiz.cpp...?!
Mind enlighten me what I am missing here??? :shock:
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: [BUG]: "Directory cannot be created" error if directory is present
« Reply #5 on: November 15, 2006, 06:38:46 pm »
The "early out" feature in CreateDirRecursively was first added in 3193 (with return value == failed) and amended in 3206 (with correct return value).
What "early out" does is abort if the requested directory already exists, instead of checking the root directory and then hangling through the entire FS hierarchy until failing in the very end.

The "early out" code is nothing but:
Code
    if(wxDirExists(full_path)) // early out
        return true;
So, in other words, "early out" does what you should have done in wiz.cpp in the first place. No special magic happens. If the path exists, then the function returns immediately (success). If it does not exist, the function attempts to create it in the same way it has been doing for years (success if the folder can be created, failure otherwise).


By the way, CreateDirRecursively has a wxLogNull object, so I don't see how this function could produce a "could not create directory" warning, as these are discarded.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
[SOLVED]: "Directory cannot be created" error if directory is present
« Reply #6 on: November 15, 2006, 09:47:22 pm »
By the way, CreateDirRecursively has a wxLogNull object, so I don't see how this function could produce a "could not create directory" warning, as these are discarded.
Sure it didn't - the error message was raised by wiz.cpp (as I said earlier... ;-)).

Anyway - after a SVN update this issue was fixed. Seems as if I had missed the one update that took care of this... :oops:
So... erm... Sorry for the noise. ;-)
With regards, Morten.
« Last Edit: November 15, 2006, 09:52:45 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ