diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-05-20 18:07:54 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-05-20 18:12:33 +0200 |
commit | f65de4feee506b80be0986ce28f7a2311e4fbe2c (patch) | |
tree | dc9bcdb650550e2e2e88c36c2024f895c17b9f6c /sal/osl/unx/file_misc.cxx | |
parent | 1122d513efbb3066b4e8aefbc8dc29ce7a7e9bcf (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/osl/unx/file_misc.cxx')
-rw-r--r-- | sal/osl/unx/file_misc.cxx | 26 |
1 files changed, 22 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); |