Create() and createDirectory() is not working properly

Hi Jules,
The create and createDirectory is not working fine with latest juce GIT code. In Mac create Directory is not creating the directory instead its creating one file of the same name. And in PC the create is not creating the file in the proper destination (even if the destination directory exist ).

Thanks
CGD

Well, this week I added a set of unit tests for the File class, and the tests definitely include createDirectory() - so I’m pretty confident that it does work correctly! Can you give me some test code that would reproduce the problem?

I m using JUCE 1.52.49, ( afraid to take latest version ) and I m working in windows XP.

juce::String sMyFolderPath( T("C:\Program Files\Common Files\MyFolder\"));
juce::File myFolder( sMyFolderPath );
			
if ( myFolder.isDirectory() == false )
{
	bool b = myFolder.createDirectory();
}

sorry little confusion…That was for mac code.

It was not able to create directory in mac. and file in PC

I found out the possible reason in the PC side.

the

void* juce_fileOpen (const File& file, bool forWriting)

has the line

if (forWriting)
    {
        h = CreateFile (file.getFullPathName(), GENERIC_WRITE, [color=#FF0000]FILE_SHARE_READ[/color], 0,
                        OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);

the third argument should be also FILE_SHARE_WRITE as the document says

juce::String sMyFolderPath( T("C:\Program Files\Common Files\MyFolder\"));

…ahem… you might want to have a careful look at those backslash escape sequences. Maybe DBG the filename that you’re trying to create before assuming that something else is failing!

that was for example… thats not the actual file name
I was using the windows call to get the file location ::SHGetSpecialFolderPath(NULL,str,CSIDL_COMMON_APPDATA,NULL);

think that it gives the path as “C:\Program Files\Common Files” i myself append the file name at the end. and i create the file name based on the time.

juce::String filePath = CommonDataPath + juce::Time::getCurrentTime().toString( true , true , true , true ) + juce::String(".xml");

and i use this path to create file using

juce::File file( filePath );
file.create()

so there is no issue in the file name…

If createDirectory failed, then pretty much no applications would work. So it’s going to take quite a lot to convince me that this isn’t just you doing something silly.

Did you actually DBG the filename you’re trying to create? If so, what is it?

…and why are you using strings, anyway? Never, never concatenate filenames using strings - always use the File class to do it safely. And why not just use File::getSpecialLocation to get the apps folder??

i got it clear…

the problem was in “:” from juce::Time::getCurrentTime().toString( true , true , true , true )…
I developed the code in mac and then tried building in PC. the Mac system accepted “:” in the file name…

i guessed u r creating valid file name for the files and throwing assertion if the filename is contains invalid characters…
I m running in debug mode still it dint throw any assertion.