summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-05-20 18:07:54 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-05-20 18:12:33 +0200
commitf65de4feee506b80be0986ce28f7a2311e4fbe2c (patch)
treedc9bcdb650550e2e2e88c36c2024f895c17b9f6c /sal
parent1122d513efbb3066b4e8aefbc8dc29ce7a7e9bcf (diff)
fdo#60338: Introduce osl_createDirectoryWithFlags
...so that utl::TempFile can pass osl_File_OpenFlag_Private and doesn't have to resort to umask (the calls to umask around Directory::create had somewhat erroneously been removed recently with 1d72a0262c4570631d0aa8f98e34e21fb9d6ae42 "Related fdo#60338: Create missing temp file dir with user's original umask," mistaking this for creation of intermediate directories in the hierarchy). On Windows, the flags argument to osl_createDirectoryWithFlags is ignored completely for now. Change-Id: Iac56a5049d579be729a3f338aa62105123edb6cb
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/file_misc.cxx26
-rw-r--r--sal/osl/w32/file_dirvol.cxx6
-rw-r--r--sal/util/sal.map1
3 files changed, 29 insertions, 4 deletions
diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx
index 787866ec48bf..eb1e15194fed 100644
--- a/sal/osl/unx/file_misc.cxx
+++ b/sal/osl/unx/file_misc.cxx
@@ -131,7 +131,8 @@ oslFileType DirectoryItem_Impl::getFileType() const
return osl_File_Type_Unknown;
}
-static oslFileError osl_psz_createDirectory(const sal_Char* pszPath);
+static oslFileError osl_psz_createDirectory(
+ char const * pszPath, sal_uInt32 flags);
static oslFileError osl_psz_removeDirectory(const sal_Char* pszPath);
oslFileError SAL_CALL osl_openDirectory(rtl_uString* ustrDirectoryURL, oslDirectory* pDirectory)
@@ -395,6 +396,13 @@ oslFileError SAL_CALL osl_releaseDirectoryItem( oslDirectoryItem Item )
oslFileError SAL_CALL osl_createDirectory( rtl_uString* ustrDirectoryURL )
{
+ return osl_createDirectoryWithFlags(
+ ustrDirectoryURL, osl_File_OpenFlag_Read | osl_File_OpenFlag_Write);
+}
+
+oslFileError osl_createDirectoryWithFlags(
+ rtl_uString * ustrDirectoryURL, sal_uInt32 flags)
+{
char path[PATH_MAX];
oslFileError eRet;
@@ -410,7 +418,7 @@ oslFileError SAL_CALL osl_createDirectory( rtl_uString* ustrDirectoryURL )
return oslTranslateFileError( OSL_FET_ERROR, errno );
#endif/* MACOSX */
- return osl_psz_createDirectory( path );
+ return osl_psz_createDirectory( path, flags );
}
oslFileError SAL_CALL osl_removeDirectory( rtl_uString* ustrDirectoryURL )
@@ -433,10 +441,20 @@ oslFileError SAL_CALL osl_removeDirectory( rtl_uString* ustrDirectoryURL )
return osl_psz_removeDirectory( path );
}
-static oslFileError osl_psz_createDirectory( const sal_Char* pszPath )
+oslFileError osl_psz_createDirectory(char const * pszPath, sal_uInt32 flags)
{
int nRet=0;
- int mode = S_IRWXU | S_IRWXG | S_IRWXO;
+ int mode
+ = (((flags & osl_File_OpenFlag_Read) == 0
+ ? 0
+ : ((flags & osl_File_OpenFlag_Private) == 0
+ ? S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH
+ : S_IRUSR | S_IXUSR))
+ | ((flags & osl_File_OpenFlag_Write) == 0
+ ? 0
+ : ((flags & osl_File_OpenFlag_Private) == 0
+ ? S_IWUSR | S_IWGRP | S_IWOTH
+ : S_IWUSR)));
nRet = mkdir(pszPath,mode);
diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index 2d2c9f6aab58..51bef22c0917 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -691,6 +691,12 @@ oslFileError SAL_CALL osl_createDirectoryPath(
oslFileError SAL_CALL osl_createDirectory(rtl_uString* strPath)
{
+ return osl_createDirectoryWithFlags(
+ strPath, osl_File_OpenFlag_Read | osl_File_OpenFlag_Write);
+}
+
+oslFileError osl_createDirectoryWithFlags(rtl_uString * strPath, sal_uInt32)
+{
rtl_uString *strSysPath = NULL;
oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
diff --git a/sal/util/sal.map b/sal/util/sal.map
index e601c6d57863..1d7d491d295a 100644
--- a/sal/util/sal.map
+++ b/sal/util/sal.map
@@ -672,6 +672,7 @@ LIBO_UDK_4.2 { # symbols available in >= LibO 4.2
LIBO_UDK_4.3 { # symbols available in >= LibO 4.3
global:
+ osl_createDirectoryWithFlags;
rtl_allocateAlignedMemory;
rtl_freeAlignedMemory;
} LIBO_UDK_4.2;