Hidden File

How do I create a hidden file, Windows and Mac? Is there a juce way of doing this?

Haven't really got a cross-platform way of doing that, as I think it depends on the filename starting with a dot on some platforms, and on file attributes on others..

Should I add File::makeHidden() that does this or would you do it? You already have isHidden()

On windows side:

bool File::setIsHidden (bool shouldBeHidden) const
{
    const DWORD oldAtts = WindowsFileHelpers::getAtts (fullPath);
    if (oldAtts == INVALID_FILE_ATTRIBUTES)
        return false;
    const DWORD newAtts = shouldBeHidden ? (oldAtts |  FILE_ATTRIBUTE_HIDDEN)
                                                       : (oldAtts & ~FILE_ATTRIBUTE_HIDDEN);
    return SetFileAttributes (fullPath.toWideCharPointer(), newAtts) != FALSE;
}

On others would renaming the file with a '.' at the beginning do it?

BTW, how do you rename a file?

This is exactly why I wouldn't add a method like that. If the method had to work by changing the file name then that's something the user would need to handle in their own code.

Renaming is with the File::moveFileTo call.  (Move and rename are closely related operations when the file is beig moved on the same partition). http://www.juce.com/doc/classFile#a43a7e37203ed65b036a2c54f0f260857

Would it be possible to add a way in the File class to set the hidden flag of any file on Windows and Mac OS X ? Thanks in advance !

Not really. On Windows it'd be doable, but I think on posix systems a file is just hidden if you put a dot in front of it, and it'd be a terrible API for the File class to automatically rename a file by adding a dot..

Would it be possible to do it only for Windows at least ? Thanks in advance ;)