44ea1e4ee2
2005/09/05 14:09:01 rt 1.2.118.1: #i54170# Change license header: remove SISSL
160 lines
3.5 KiB
C++
160 lines
3.5 KiB
C++
/*************************************************************************
|
|
*
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
*
|
|
* $RCSfile: ploc.cxx,v $
|
|
*
|
|
* $Revision: 1.3 $
|
|
*
|
|
* last change: $Author: rt $ $Date: 2005-09-08 08:07:09 $
|
|
*
|
|
* The Contents of this file are made available subject to
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
|
*
|
|
*
|
|
* GNU Lesser General Public License Version 2.1
|
|
* =============================================
|
|
* Copyright 2005 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
|
|
*
|
|
************************************************************************/
|
|
|
|
#include <precomp.h>
|
|
#include <cosv/ploc.hxx>
|
|
|
|
// NOT FULLY DECLARED SERVICES
|
|
#include <cosv/bstream.hxx>
|
|
// #include <ctype.h>
|
|
|
|
|
|
namespace csv
|
|
{
|
|
namespace ploc
|
|
{
|
|
|
|
|
|
Path::Path( const char * i_sPath,
|
|
bool i_bPathIsAlwaysDir,
|
|
const char * i_sDelimiter )
|
|
: pRoot(0)
|
|
// aPath,
|
|
// sFile
|
|
{
|
|
Set(i_sPath, i_bPathIsAlwaysDir, i_sDelimiter );
|
|
}
|
|
|
|
Path::Path( const Path & i_rPath )
|
|
: pRoot(i_rPath.pRoot->CreateCopy()),
|
|
aPath(i_rPath.aPath),
|
|
sFile(i_rPath.sFile)
|
|
{
|
|
}
|
|
|
|
Path::~Path()
|
|
{
|
|
}
|
|
|
|
Path &
|
|
Path::operator=( const Path & i_rPath )
|
|
{
|
|
pRoot = i_rPath.pRoot->CreateCopy();
|
|
aPath = i_rPath.aPath;
|
|
sFile = i_rPath.sFile;
|
|
return *this;
|
|
}
|
|
|
|
|
|
void
|
|
Path::Set( const char * i_sPath,
|
|
bool i_bPathIsAlwaysDir,
|
|
const char * i_sDelimiter )
|
|
{
|
|
if ( *i_sDelimiter != '\\' AND *i_sDelimiter != '/' )
|
|
return;
|
|
|
|
const char * pRestPath = 0;
|
|
pRoot = Root::Create_( pRestPath, i_sPath, i_sDelimiter );
|
|
if (pRestPath == 0)
|
|
return;
|
|
|
|
aPath.Set(pRestPath, i_bPathIsAlwaysDir, i_sDelimiter);
|
|
|
|
if (NOT i_bPathIsAlwaysDir)
|
|
{
|
|
const char * pFile = strrchr( pRestPath, *i_sDelimiter );
|
|
if (pFile == 0)
|
|
pFile = pRestPath;
|
|
else
|
|
pFile++;
|
|
sFile = pFile;
|
|
}
|
|
}
|
|
|
|
void
|
|
Path::SetFile( const String & i_sName )
|
|
{
|
|
sFile = i_sName;
|
|
}
|
|
|
|
const char *
|
|
Path::FileEnding() const
|
|
{
|
|
const char * pEnd = strrchr(sFile, '.');
|
|
if (pEnd != 0)
|
|
++pEnd;
|
|
else
|
|
pEnd = "";
|
|
return pEnd;
|
|
}
|
|
|
|
bool
|
|
Path::IsValid() const { return RootDir().OwnDelimiter() != 0; }
|
|
|
|
void
|
|
Path::Get( ostream & o_rPath ) const
|
|
{
|
|
if (NOT IsValid())
|
|
return;
|
|
|
|
pRoot->Get( o_rPath );
|
|
aPath.Get( o_rPath, pRoot->OwnDelimiter() );
|
|
|
|
if ( sFile.length() > 0 )
|
|
o_rPath << sFile;
|
|
|
|
}
|
|
|
|
void
|
|
Path::Get( bostream & o_rPath ) const
|
|
{
|
|
if (NOT IsValid())
|
|
return;
|
|
|
|
pRoot->Get( o_rPath );
|
|
aPath.Get( o_rPath, pRoot->OwnDelimiter() );
|
|
|
|
if ( sFile.length() > 0 )
|
|
o_rPath.write( sFile );
|
|
}
|
|
|
|
|
|
|
|
} // namespace ploc
|
|
} // namespace csv
|
|
|
|
|
|
|