diff options
author | Kai Sommerfeld <kso@openoffice.org> | 2000-10-16 13:56:13 +0000 |
---|---|---|
committer | Kai Sommerfeld <kso@openoffice.org> | 2000-10-16 13:56:13 +0000 |
commit | d3329bacd8a925ec070ad06ea3d9a6a026a3696b (patch) | |
tree | cd3503c80360b6d21e0cf4a615967f3357a4d3c8 /ucb/source/ucp/webdav/NeonUri.cxx | |
parent | 4ab353132a0d57510151f9844d8c2012feca0dad (diff) |
Moved here from module 'chaos'.
Diffstat (limited to 'ucb/source/ucp/webdav/NeonUri.cxx')
-rw-r--r-- | ucb/source/ucp/webdav/NeonUri.cxx | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/ucb/source/ucp/webdav/NeonUri.cxx b/ucb/source/ucp/webdav/NeonUri.cxx new file mode 100644 index 000000000000..c7a8ce593726 --- /dev/null +++ b/ucb/source/ucp/webdav/NeonUri.cxx @@ -0,0 +1,141 @@ +/************************************************************************* + * + * $RCSfile: NeonUri.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: kso $ $Date: 2000-10-16 14:55:20 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "NeonUri.hxx" +#include "DAVException.hxx" + +using namespace rtl; +using namespace webdav_ucp; + + +uri NeonUri::sUriDefaults = { "http", NULL, DEFAULT_HTTP_PORT, NULL }; + +// ------------------------------------------------------------------- +// Constructor +// ------------------------------------------------------------------- +NeonUri::NeonUri( const OUString & inUri ) +{ + if ( inUri.getLength() <= 0 ) + throw DAVException( DAVException::DAV_INVALID_ARG ); + + OString theInputUri ( + inUri.getStr(), inUri.getLength(), RTL_TEXTENCODING_UTF8); + + uri theUri; + if ( uri_parse( theInputUri.getStr(), &theUri, &sUriDefaults ) != 0 ) + { + uri_free( &theUri ); + throw DAVException( DAVException::DAV_INVALID_ARG ); + } + + mScheme = OStringToOUString( theUri.scheme, RTL_TEXTENCODING_UTF8 ); + mHostName = OStringToOUString( theUri.host, RTL_TEXTENCODING_UTF8 ); + mPort = theUri.port; + mPath = OStringToOUString( theUri.path, RTL_TEXTENCODING_UTF8 ); + + calculateURI (); +} + +// ------------------------------------------------------------------- +// Destructor +// ------------------------------------------------------------------- +NeonUri::~NeonUri( ) +{ +} + +void NeonUri::calculateURI () +{ + mURI = mScheme; + mURI += OUString::createFromAscii ("://"); + mURI += mHostName; + mURI += OUString::createFromAscii (":"); + mURI += OUString::valueOf (mPort); + mURI += mPath; +} + +::rtl::OUString NeonUri::GetPathBaseName () const +{ + sal_Int32 nPos = mPath.lastIndexOf ('/'); + if (nPos == mPath.getLength () - 1) + { + // Trailing slash found. Skip. + nPos = mPath.lastIndexOf ('/', nPos); + } + if (nPos != -1) + return mPath.copy (nPos + 1, mPath.getLength () - nPos - 1); + else + return OUString::createFromAscii ("/"); +} + +::rtl::OUString NeonUri::GetPathDirName () const +{ + sal_Int32 nPos = mPath.lastIndexOf ('/'); + if (nPos == mPath.getLength () - 1) + { + // Trailing slash found. Skip. + nPos = mPath.lastIndexOf ('/', nPos); + } + if (nPos != -1) + return mPath.copy (0, nPos + 1); + else + return OUString::createFromAscii ("/"); +} + |