1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Allow write access to all files if a user has effective root permissions on linux

This commit is contained in:
hogliux 2016-06-15 17:28:42 +01:00
parent 074c90984e
commit 16fde6798b

View file

@ -332,11 +332,21 @@ uint64 File::getFileIdentifier() const
return juce_stat (fullPath, info) ? (uint64) info.st_ino : 0;
}
static bool hasEffectiveRootFilePermissions()
{
#if JUCE_LINUX
return (geteuid() == 0);
#else
return false;
#endif
}
//==============================================================================
bool File::hasWriteAccess() const
{
if (exists())
return access (fullPath.toUTF8(), W_OK) == 0;
return (hasEffectiveRootFilePermissions()
|| access (fullPath.toUTF8(), W_OK) == 0);
if ((! isDirectory()) && fullPath.containsChar (separator))
return getParentDirectory().hasWriteAccess();