diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-08-30 12:23:43 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-08-30 13:30:59 +0200 |
commit | cc4edc0f29c034722f10ab289eb0d8d563a8632c (patch) | |
tree | d4727bb8a393a7cffd692ed6a04a4719fd72eac2 | |
parent | d418eaed304d69f5a766a9ee5a907a71771b0223 (diff) |
Clean up some osl::X, X_u function combos
(adapting call sites where necessary)
Change-Id: Ib9ad1122571b1c00ebbb4638f94eb5698b18a1a7
Reviewed-on: https://gerrit.libreoffice.org/78289
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r-- | sal/osl/unx/file_misc.cxx | 2 | ||||
-rw-r--r-- | sal/osl/unx/file_stat.cxx | 4 | ||||
-rw-r--r-- | sal/osl/unx/process_impl.cxx | 7 | ||||
-rw-r--r-- | sal/osl/unx/uunxapi.cxx | 30 | ||||
-rw-r--r-- | sal/osl/unx/uunxapi.hxx | 46 |
5 files changed, 26 insertions, 63 deletions
diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx index 436cf07b271f..ac2b1de2eca1 100644 --- a/sal/osl/unx/file_misc.cxx +++ b/sal/osl/unx/file_misc.cxx @@ -371,7 +371,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString* ustrFileURL, oslDirector osl_systemPathRemoveSeparator(ustrSystemPath); - if (access_u(ustrSystemPath, F_OK) == -1) + if (osl::access(OUString::unacquired(&ustrSystemPath), F_OK) == -1) { osl_error = oslTranslateFileError(errno); } diff --git a/sal/osl/unx/file_stat.cxx b/sal/osl/unx/file_stat.cxx index f6a2299643cc..5f5c11eb54a8 100644 --- a/sal/osl/unx/file_stat.cxx +++ b/sal/osl/unx/file_stat.cxx @@ -103,10 +103,10 @@ namespace { pStat->uValidFields |= osl_FileStatus_Mask_Attributes; - if (access_u(file_path.pData, W_OK) < 0) + if (osl::access(file_path, W_OK) < 0) pStat->uAttributes |= osl_File_Attribute_ReadOnly; - if (access_u(file_path.pData, X_OK) == 0) + if (osl::access(file_path, X_OK) == 0) pStat->uAttributes |= osl_File_Attribute_Executable; } diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx index 2b59e9f3147c..35a5b90ece0d 100644 --- a/sal/osl/unx/process_impl.cxx +++ b/sal/osl/unx/process_impl.cxx @@ -241,11 +241,10 @@ void SAL_CALL osl_setCommandArgs (int argc, char ** argv) } } #endif - rtl_uString * pArg0 = nullptr; - if (realpath_u (ppArgs[0], &pArg0)) + OUString pArg0; + if (osl::realpath (OUString::unacquired(&ppArgs[0]), pArg0)) { - osl_getFileURLFromSystemPath (pArg0, &(ppArgs[0])); - rtl_uString_release (pArg0); + osl_getFileURLFromSystemPath (pArg0.pData, &(ppArgs[0])); } } g_command_args.m_nCount = argc; diff --git a/sal/osl/unx/uunxapi.cxx b/sal/osl/unx/uunxapi.cxx index f35c398cad20..45de25280980 100644 --- a/sal/osl/unx/uunxapi.cxx +++ b/sal/osl/unx/uunxapi.cxx @@ -31,10 +31,9 @@ #include <osl/detail/android-bootstrap.h> #endif -static OString OUStringToOString(const rtl_uString* s) +static OString OUStringToOString(const OUString& s) { - return OUStringToOString(OUString(const_cast<rtl_uString*>(s)), - osl_getThreadTextEncoding()); + return OUStringToOString(s, osl_getThreadTextEncoding()); } #if HAVE_FEATURE_MACOSX_SANDBOX @@ -157,7 +156,7 @@ static OString macxp_resolveAliasAndConvert(OString const & p) } #endif /* MACOSX */ -int access_u(const rtl_uString* pustrPath, int mode) +int osl::access(const OUString& pustrPath, int mode) { OString fn = OUStringToOString(pustrPath); #ifdef ANDROID @@ -181,7 +180,7 @@ int access_u(const rtl_uString* pustrPath, int mode) accessFilePathState *state = prepare_to_access_file_path(fn.getStr()); - int result = access(fn.getStr(), mode); + int result = ::access(fn.getStr(), mode); int saved_errno = errno; if (result == -1) SAL_INFO("sal.file", "access(" << fn.getStr() << ",0" << std::oct << mode << std::dec << "): " << UnixErrnoString(saved_errno)); @@ -195,17 +194,16 @@ int access_u(const rtl_uString* pustrPath, int mode) return result; } -bool realpath_u(const rtl_uString* pustrFileName, rtl_uString** ppustrResolvedName) +bool osl::realpath(const OUString& pustrFileName, OUString& ppustrResolvedName) { OString fn = OUStringToOString(pustrFileName); #ifdef ANDROID if (fn == "/assets" || fn.startsWith("/assets/")) { - if (access_u(pustrFileName, F_OK) == -1) + if (osl::access(pustrFileName, F_OK) == -1) return false; - rtl_uString silly(*pustrFileName); - rtl_uString_assign(ppustrResolvedName, &silly); + ppustrResolvedName = pustrFileName; return true; } @@ -218,7 +216,7 @@ bool realpath_u(const rtl_uString* pustrFileName, rtl_uString** ppustrResolvedNa accessFilePathState *state = prepare_to_access_file_path(fn.getStr()); char rp[PATH_MAX]; - bool bRet = realpath(fn.getStr(), rp); + bool bRet = ::realpath(fn.getStr(), rp); int saved_errno = errno; if (!bRet) SAL_INFO("sal.file", "realpath(" << fn.getStr() << "): " << UnixErrnoString(saved_errno)); @@ -229,10 +227,8 @@ bool realpath_u(const rtl_uString* pustrFileName, rtl_uString** ppustrResolvedNa if (bRet) { - OUString resolved = OStringToOUString(OString(static_cast<sal_Char*>(rp)), + ppustrResolvedName = OStringToOUString(OString(static_cast<sal_Char*>(rp)), osl_getThreadTextEncoding()); - - rtl_uString_assign(ppustrResolvedName, resolved.pData); } errno = saved_errno; @@ -290,7 +286,7 @@ int lstat_c(const char* cpPath, struct stat* buf) return result; } -int lstat_u(const rtl_uString* pustrPath, struct stat* buf) +int osl::lstat(const OUString& pustrPath, struct stat& buf) { OString fn = OUStringToOString(pustrPath); @@ -298,16 +294,16 @@ int lstat_u(const rtl_uString* pustrPath, struct stat* buf) fn = macxp_resolveAliasAndConvert(fn); #endif - return lstat_c(fn.getStr(), buf); + return lstat_c(fn.getStr(), &buf); } -int mkdir_u(const rtl_uString* path, mode_t mode) +int osl::mkdir(const OUString& path, mode_t mode) { OString fn = OUStringToOString(path); accessFilePathState *state = prepare_to_access_file_path(fn.getStr()); - int result = mkdir(OUStringToOString(path).getStr(), mode); + int result = ::mkdir(OUStringToOString(path).getStr(), mode); int saved_errno = errno; if (result == -1) SAL_INFO("sal.file", "mkdir(" << OUStringToOString(path).getStr() << ",0" << std::oct << mode << std::dec << "): " << UnixErrnoString(saved_errno)); diff --git a/sal/osl/unx/uunxapi.hxx b/sal/osl/unx/uunxapi.hxx index 5030b75ca214..1d0b26c92dc2 100644 --- a/sal/osl/unx/uunxapi.hxx +++ b/sal/osl/unx/uunxapi.hxx @@ -28,30 +28,10 @@ #include <rtl/ustring.hxx> -int access_u(const rtl_uString* pustrPath, int mode); - -/*********************************** - @descr - The return value differs from the - realpath function - - @returns sal_True on success else - sal_False - - @see realpath - **********************************/ -bool realpath_u( - const rtl_uString* pustrFileName, - rtl_uString** ppustrResolvedName); - int stat_c(const char *cpPath, struct stat* buf); int lstat_c(const char *cpPath, struct stat* buf); -int lstat_u(const rtl_uString* pustrPath, struct stat* buf); - -int mkdir_u(const rtl_uString* path, mode_t mode); - int open_c(const char *cpPath, int oflag, int mode); int utime_c(const char *cpPath, struct utimbuf *times); @@ -60,10 +40,7 @@ int ftruncate_with_name(int fd, sal_uInt64 uSize, rtl_String* path); namespace osl { - inline int access(const OUString& ustrPath, int mode) - { - return access_u(ustrPath.pData, mode); - } + int access(const OUString& ustrPath, int mode); /*********************************** osl::realpath @@ -78,22 +55,13 @@ namespace osl @see realpath **********************************/ - inline bool realpath( + bool realpath( const OUString& ustrFileName, - OUString& ustrResolvedName) - { - return realpath_u(ustrFileName.pData, &ustrResolvedName.pData); - } - - inline int lstat(const OUString& ustrPath, struct stat& buf) - { - return lstat_u(ustrPath.pData, &buf); - } - - inline int mkdir(const OUString& aPath, mode_t aMode) - { - return mkdir_u(aPath.pData, aMode); - } + OUString& ustrResolvedName); + + int lstat(const OUString& ustrPath, struct stat& buf); + + int mkdir(const OUString& aPath, mode_t aMode); } // end namespace osl #endif // INCLUDED_SAL_OSL_UNX_UUNXAPI_HXX |