diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-10 01:15:27 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-10 01:15:27 +0000 |
commit | b6e09a3a8ea5f1338d089a29eb6e08f00f03f1aa (patch) | |
tree | 7dee2cbb5c94d3371357f796d42e344e1305ce9c /kdirstat/kdirsaver.cpp | |
download | kdirstat-b6e09a3a8ea5f1338d089a29eb6e08f00f03f1aa.tar.gz kdirstat-b6e09a3a8ea5f1338d089a29eb6e08f00f03f1aa.zip |
Added abandoned KDE3 version of kdirstat
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kdirstat@1088039 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdirstat/kdirsaver.cpp')
-rw-r--r-- | kdirstat/kdirsaver.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/kdirstat/kdirsaver.cpp b/kdirstat/kdirsaver.cpp new file mode 100644 index 0000000..2be9074 --- /dev/null +++ b/kdirstat/kdirsaver.cpp @@ -0,0 +1,71 @@ +/* + * 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 QString & newPath ) +{ + /* + * No need to actually save the current working directory: This object + * includes a QDir 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 QString & newPath ) +{ + if ( ! newPath.isEmpty() ) + { + chdir( newPath ); + } +} + + +QString +KDirSaver::currentDirPath() const +{ + return QDir::currentDirPath(); +} + + +void +KDirSaver::restore() +{ + chdir( oldWorkingDir.path() ); +} + + +// EOF |