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>
This commit is contained in:
Stephan Bergmann 2019-08-30 12:23:43 +02:00
parent d418eaed30
commit cc4edc0f29
5 changed files with 24 additions and 61 deletions

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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));

View File

@ -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);
}
OUString& ustrResolvedName);
inline int lstat(const OUString& ustrPath, struct stat& buf)
{
return lstat_u(ustrPath.pData, &buf);
}
int lstat(const OUString& ustrPath, struct stat& buf);
inline int mkdir(const OUString& aPath, mode_t aMode)
{
return mkdir_u(aPath.pData, aMode);
}
int mkdir(const OUString& aPath, mode_t aMode);
} // end namespace osl
#endif // INCLUDED_SAL_OSL_UNX_UUNXAPI_HXX