Pointwise Plugin SDK
PwpCwd.cxx
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * class PwpCwd
4  *
5  * (C) 2021 Cadence Design Systems, Inc. All rights reserved worldwide.
6  *
7  ***************************************************************************/
8 
9 #include "pwpPlatform.h"
10 
11 #include "PwpCwd.h"
12 
13 
14 PwpCwd::PwpCwd(const char *dir) :
15  depth_(0)
16 {
17  push(dir);
18 }
19 
21 {
22  // clear this objects stack
23  while (pop());
24 }
25 
26 bool
27 PwpCwd::push(const char *dir)
28 {
29  bool ret = pushDir(dir);
30  if (ret) {
31  ++depth_;
32  }
33  return ret;
34 }
35 
36 bool
38 {
39  bool ret = false;
40  if (0 < depth_) {
41  ret = popDir();
42  --depth_;
43  }
44  return ret;
45 }
46 
47 bool
48 PwpCwd::pushDir(const char *dir)
49 {
50  return (nullptr != dir) && ('\0' != dir[0]) && (0 == pwpCwdPush(dir));
51 }
52 
53 bool
55 {
56  return 0 == pwpCwdPop();
57 }
PwpCwd::push
bool push(const char *dir)
Sets the current working directory.
Definition: PwpCwd.cxx:27
PwpCwd::pushDir
static bool pushDir(const char *dir)
Sets the current working directory.
Definition: PwpCwd.cxx:48
PwpCwd::PwpCwd
PwpCwd(const char *dir=0)
Constructor.
Definition: PwpCwd.cxx:14
PwpCwd::~PwpCwd
~PwpCwd()
Destructor.
Definition: PwpCwd.cxx:20
pwpPlatform.h
Cross Platform Functions.
PwpCwd::depth_
int depth_
The stack depth.
Definition: PwpCwd.h:117
pwpCwdPop
int pwpCwdPop(void)
Restore the current directory.
Definition: pwpPlatform.cxx:486
PwpCwd.h
PwpCwd::popDir
static bool popDir()
Restores the current working directory.
Definition: PwpCwd.cxx:54
PwpCwd::pop
bool pop()
Restores the current working directory.
Definition: PwpCwd.cxx:37
pwpCwdPush
int pwpCwdPush(const char *dir)
Change the current directory using a stack.
Definition: pwpPlatform.cxx:461