From 32a6a0891fb5f2d893cca656cd44afd0bcbe3272 Mon Sep 17 00:00:00 2001 From: Moritz Bechler Date: Mon, 19 Dec 2011 16:36:31 +0100 Subject: fdo#43095: allow the use of real access() calls --- sal/osl/unx/file_stat.cxx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'sal/osl') diff --git a/sal/osl/unx/file_stat.cxx b/sal/osl/unx/file_stat.cxx index 674e6037e308..6b2407adc0fb 100644 --- a/sal/osl/unx/file_stat.cxx +++ b/sal/osl/unx/file_stat.cxx @@ -163,6 +163,22 @@ namespace /* private */ } } + /* contrary to what is stated above the use of access calls + is required on network file systems not using unix semantics + (AFS) + */ + inline void set_file_access_real_rights(const rtl::OUString& file_path, oslFileStatus* pStat) + { + pStat->uValidFields |= osl_FileStatus_Mask_Attributes; + + if (access_u(file_path.pData, W_OK) < 0) + pStat->uAttributes |= osl_File_Attribute_ReadOnly; + + if (access_u(file_path.pData, X_OK) == 0) + pStat->uAttributes |= osl_File_Attribute_Executable; + } + + inline void set_file_hidden_status(const rtl::OUString& file_path, oslFileStatus* pStat) { pStat->uAttributes = osl::systemPathIsHiddenFileOrDirectoryEntry(file_path) ? osl_File_Attribute_Hidden : 0; @@ -177,10 +193,15 @@ namespace /* private */ set_file_hidden_status(file_path, pStat); set_file_access_mask(file_stat, pStat); +#ifdef FAKE_ACCESS_RIGHTS // we set the file access rights only on demand // because it's potentially expensive if (uFieldMask & osl_FileStatus_Mask_Attributes) set_file_access_rights(file_stat, pStat); +#else + if (uFieldMask & osl_FileStatus_Mask_Attributes) + set_file_access_real_rights(file_path, pStat); +#endif } inline void set_file_access_time(const struct stat& file_stat, oslFileStatus* pStat) -- cgit