summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-10-21 10:21:01 +0200
committerNoel Grandin <noel@peralex.com>2013-10-23 08:29:15 +0200
commit7a06928bcf638e1eeedebc9d53c306a1b852cc9b (patch)
treec0402c2da4e2c522ecf32a0b413128f727cbc0fa /unotools
parenta55d02bacb2c8f21cba759c8fe3931df07a85b0c (diff)
convert code to use OUString::endsWith
Convert places that call aStr[aStr.getLength()-1] == 'x' to use the shorter form aStr.endsWith("x") Change-Id: I1b3a19c0e89b8989cdbeed440f95fc76f9a4b6b6
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/config/bootstrap.cxx4
-rw-r--r--unotools/source/ucbhelper/tempfile.cxx13
2 files changed, 8 insertions, 9 deletions
diff --git a/unotools/source/config/bootstrap.cxx b/unotools/source/config/bootstrap.cxx
index fb213a35ff31..f05e204937fe 100644
--- a/unotools/source/config/bootstrap.cxx
+++ b/unotools/source/config/bootstrap.cxx
@@ -209,7 +209,7 @@ bool implNormalizeURL(OUString & _sURL, osl::DirectoryItem& aDirItem)
// #109863# sal/osl returns final slash for file URLs contradicting
// the URL/URI RFCs.
- if ( aNormalizedURL.getStr()[aNormalizedURL.getLength()-1] != cURLSeparator )
+ if ( !aNormalizedURL.endsWith(OUString(cURLSeparator)) )
_sURL = aNormalizedURL;
else
_sURL = aNormalizedURL.copy( 0, aNormalizedURL.getLength()-1 );
@@ -326,7 +326,7 @@ PathStatus getDerivedPath(
// do we have a base path ?
if (!_aBaseURL.isEmpty())
{
- OSL_PRECOND(_aBaseURL[_aBaseURL.getLength()-1] != cURLSeparator,"Unexpected: base URL ends in slash");
+ OSL_PRECOND(!_aBaseURL.endsWith(OUString(cURLSeparator)), "Unexpected: base URL ends in slash");
sDerivedURL = OUStringBuffer(_aBaseURL).append(cURLSeparator).append(_sRelativeURL).makeStringAndClear();
diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx
index 13128b6880bd..0ffae6db625a 100644
--- a/unotools/source/ucbhelper/tempfile.cxx
+++ b/unotools/source/ucbhelper/tempfile.cxx
@@ -64,11 +64,11 @@ OUString getParentName( const OUString& aFileName )
sal_Int32 lastIndex = aFileName.lastIndexOf( sal_Unicode('/') );
OUString aParent = aFileName.copy( 0, lastIndex );
- if( aParent[ aParent.getLength()-1] == sal_Unicode(':') && aParent.getLength() == 6 )
- aParent += OUString("/");
+ if( aParent.endsWith(":") && aParent.getLength() == 6 )
+ aParent += "/";
if( 0 == aParent.compareToAscii( "file://" ) )
- aParent = OUString("file:///");
+ aParent = "file:///";
return aParent;
}
@@ -80,7 +80,7 @@ bool ensuredir( const OUString& rUnqPath )
return false;
// remove trailing slash
- if ( rUnqPath[ rUnqPath.getLength() - 1 ] == sal_Unicode( '/' ) )
+ if ( rUnqPath.endsWith("/") )
aPath = rUnqPath.copy( 0, rUnqPath.getLength() - 1 );
else
aPath = rUnqPath;
@@ -172,8 +172,7 @@ OUString ConstructTempDir_Impl( const OUString* pParent )
}
// Make sure that directory ends with a separator
- sal_Int32 i = aName.getLength();
- if( i>0 && aName[i-1] != '/' )
+ if( !aName.isEmpty() && !aName.endsWith("/") )
aName += "/";
return aName;
@@ -434,7 +433,7 @@ OUString TempFile::SetTempNameBaseDirectory( const OUString &rBaseName )
OUString aUnqPath( rBaseName );
// remove trailing slash
- if ( rBaseName[ rBaseName.getLength() - 1 ] == sal_Unicode( '/' ) )
+ if ( rBaseName.endsWith("/") )
aUnqPath = rBaseName.copy( 0, rBaseName.getLength() - 1 );
// try to create the directory