You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kdirstat/kdirstat/kdirsaver.cpp

72 lines
1.1 KiB

/*
* File name: kdirsaver.cpp
* Summary: Utility object to save current working directory
* License: LGPL - See file COPYING.LIB for details.
* Author: Stefan Hundhammer <sh@suse.de>
*
* Updated: 2003-01-07
*/
#include <unistd.h>
#include <kdebug.h>
#include "kdirsaver.h"
KDirSaver::KDirSaver( const TQString & newPath )
{
/*
* No need to actually save the current working directory: This object
* includes a TQDir whose default constructor constructs a directory object
* that contains the current working directory. Just what is needed here.
*/
cd( newPath );
}
KDirSaver::KDirSaver( const KURL & url )
{
if ( url.isLocalFile() )
{
cd( url.path() );
}
else
{
kdError() << k_funcinfo << "Can't change dir to remote location " << url.url() << endl;
}
}
KDirSaver::~KDirSaver()
{
restore();
}
void
KDirSaver::cd( const TQString & newPath )
{
if ( ! newPath.isEmpty() )
{
chdir( newPath );
}
}
TQString
KDirSaver::currentDirPath() const
{
return TQDir::currentDirPath();
}
void
KDirSaver::restore()
{
chdir( oldWorkingDir.path() );
}
// EOF