News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

[BUG]: "Directory cannot be created" error if directory is present

Started by MortenMacFly, November 15, 2006, 05:31:02 PM

Previous topic - Next topic

MortenMacFly

- 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

MortenMacFly

Ok - it errors in wiz.cpp (scripted wizard plugin) at line 327:
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*
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

thomas

"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

MortenMacFly

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...?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

MortenMacFly

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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

thomas

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:
    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."

MortenMacFly

Quote from: thomas on November 15, 2006, 06:38:46 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]