Author Topic: IO.CreateDirectory does not work  (Read 3941 times)

Offline Lazybones

  • Multiple posting newcomer
  • *
  • Posts: 14
IO.CreateDirectory does not work
« on: February 27, 2008, 04:13:14 pm »
Hi there,

I am trying to write a script plugin which copies all project files to a backupdirectory. In this script I want to use the function IO.CreateDirectory in this way:

Code
    	local project = GetProjectManager().GetActiveProject();
       
if (!IsNull(project))
        {
local basepath = project.GetCommonTopLevelPath();

if (IO.CreateDirectory(basepath + _T("milestones"), 0755) )
{
::ShowMessage(_T("No Error creating directory"));
}
else
{
::ShowMessage(_T("Error creating directory"));
}
        }

the message "No Error creating directory" is displayed correctly but the directory is not created.

Is there any mistake in my script?

I am using WinXP and CodeBlocks svn-build 4898.

Thanks for your help!
 Sven

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: IO.CreateDirectory does not work
« Reply #1 on: February 27, 2008, 04:45:09 pm »
Doesn't look like there is a mistake. I don't see a mistake in reporting failure to create a directory either, however.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Lazybones

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: IO.CreateDirectory does not work
« Reply #2 on: February 27, 2008, 05:06:08 pm »
I had to replace the Windows-Backslashes in the directory by slashes, then creating the directory worked fine:
Code
		local basepath = project.GetCommonTopLevelPath();
local milestonepath = basepath + _T("milestones");
milestonepath.Replace(_T("\\"), _T("/"));

if (IO.CreateDirectory(milestonepath, 0755) )
...
Maybe there is still a bug?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: IO.CreateDirectory does not work
« Reply #3 on: February 27, 2008, 09:04:09 pm »
Hmm.. that is funny, this shouldn't be necessary...
That may be a wxWidgets bug. The application calls wxFileName::Normalize, which should whack slashes/backslashes and every other path component so it works, but apparently it doesn't... :(
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."