blob: 2f1b79d989861aa8089263fd2c9e9cabb98cdd97 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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 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
|