Browse Source

Merge remote-tracking branch 'gh/master' into develop

tags/2021-05-28
jules 11 years ago
parent
commit
4a5a1d7a58
4 changed files with 39 additions and 9 deletions
  1. +5
    -0
      modules/juce_core/files/juce_File.cpp
  2. +8
    -0
      modules/juce_core/files/juce_File.h
  3. +20
    -9
      modules/juce_core/native/juce_posix_SharedCode.h
  4. +6
    -0
      modules/juce_core/native/juce_win32_Files.cpp

+ 5
- 0
modules/juce_core/files/juce_File.cpp View File

@@ -219,6 +219,11 @@ bool File::setReadOnly (const bool shouldBeReadOnly,
return setFileReadOnlyInternal (shouldBeReadOnly) && worked;
}
bool File::setExecutePermission (bool shouldBeExecutable) const
{
return setFileExecutableInternal (shouldBeExecutable);
}
bool File::deleteRecursively() const
{
bool worked = true;


+ 8
- 0
modules/juce_core/files/juce_File.h View File

@@ -348,6 +348,13 @@ public:
bool setReadOnly (bool shouldBeReadOnly,
bool applyRecursively = false) const;
/** Changes the execute-permissions of a file.
@param shouldBeExecutable whether to add or remove execute-permission
@returns true if it manages to change the file's permissions.
*/
bool setExecutePermission (bool shouldBeExecutable) const;
/** Returns true if this file is a hidden or system file.
The criteria for deciding whether a file is hidden are platform-dependent.
*/
@@ -968,6 +975,7 @@ private:
bool setFileTimesInternal (int64 m, int64 a, int64 c) const;
void getFileTimesInternal (int64& m, int64& a, int64& c) const;
bool setFileReadOnlyInternal (bool) const;
bool setFileExecutableInternal (bool) const;
};
#endif // JUCE_FILE_H_INCLUDED

+ 20
- 9
modules/juce_core/native/juce_posix_SharedCode.h View File

@@ -304,23 +304,33 @@ bool File::hasWriteAccess() const
return false;
}
bool File::setFileReadOnlyInternal (const bool shouldBeReadOnly) const
static bool setFileModeFlags (const String& fullPath, mode_t flags, bool shouldSet) noexcept
{
juce_statStruct info;
if (! juce_stat (fullPath, info))
return false;
info.st_mode &= 0777; // Just permissions
info.st_mode &= 0777;
if (shouldBeReadOnly)
info.st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
if (shouldSet)
info.st_mode |= flags;
else
// Give everybody write permission?
info.st_mode |= S_IWUSR | S_IWGRP | S_IWOTH;
info.st_mode &= ~flags;
return chmod (fullPath.toUTF8(), info.st_mode) == 0;
}
bool File::setFileReadOnlyInternal (bool shouldBeReadOnly) const
{
// Hmm.. should we give global write permission or just the current user?
return setFileModeFlags (fullPath, S_IWUSR | S_IWGRP | S_IWOTH, ! shouldBeReadOnly);
}
bool File::setFileExecutableInternal (bool shouldBeExecutable) const
{
return setFileModeFlags (fullPath, S_IXUSR | S_IXGRP | S_IXOTH, shouldBeExecutable);
}
void File::getFileTimesInternal (int64& modificationTime, int64& accessTime, int64& creationTime) const
{
modificationTime = 0;
@@ -328,11 +338,12 @@ void File::getFileTimesInternal (int64& modificationTime, int64& accessTime, int
creationTime = 0;
juce_statStruct info;
if (juce_stat (fullPath, info))
{
modificationTime = (int64) info.st_mtime * 1000;
accessTime = (int64) info.st_atime * 1000;
creationTime = (int64) info.st_ctime * 1000;
modificationTime = (int64) info.st_mtime * 1000;
accessTime = (int64) info.st_atime * 1000;
creationTime = (int64) info.st_ctime * 1000;
}
}


+ 6
- 0
modules/juce_core/native/juce_win32_Files.cpp View File

@@ -163,6 +163,12 @@ bool File::setFileReadOnlyInternal (const bool shouldBeReadOnly) const
|| SetFileAttributes (fullPath.toWideCharPointer(), newAtts) != FALSE;
}
bool File::setFileExecutableInternal (bool shouldBeExecutable)
{
// XXX is this possible?
return false;
}
bool File::isHidden() const
{
return (WindowsFileHelpers::getAtts (fullPath) & FILE_ATTRIBUTE_HIDDEN) != 0;


Loading…
Cancel
Save