X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3f66f6a5b3583b02c34854556eb83e3a808524ce..7dd6983e0bc7dc7d75b0a86e09da72e9c621e221:/src/common/filename.cpp diff --git a/src/common/filename.cpp b/src/common/filename.cpp index c0b38a5282..d538ebcc38 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -2572,6 +2572,37 @@ wxString wxFileName::StripExtension(const wxString& fullpath) return fn.GetFullPath(); } +// ---------------------------------------------------------------------------- +// file permissions functions +// ---------------------------------------------------------------------------- + +bool wxFileName::SetPermissions(int permissions) +{ + // Don't do anything for a symlink but first make sure it is one. + if ( m_dontFollowLinks && + Exists(wxFILE_EXISTS_SYMLINK|wxFILE_EXISTS_NO_FOLLOW) ) + { + // Looks like changing permissions for a symlinc is only supported + // on BSD where lchmod is present and correctly implemented. + // http://lists.gnu.org/archive/html/bug-coreutils/2009-09/msg00268.html + return false; + } + +#ifdef __WINDOWS__ + int accMode = 0; + + if ( permissions & (wxS_IRUSR|wxS_IRGRP|wxS_IROTH) ) + accMode = _S_IREAD; + + if ( permissions & (wxS_IWUSR|wxS_IWGRP|wxS_IWOTH) ) + accMode |= _S_IWRITE; + + permissions = accMode; +#endif // __WINDOWS__ + + return wxChmod(GetFullPath(), permissions) == 0; +} + // ---------------------------------------------------------------------------- // time functions // ----------------------------------------------------------------------------