-
Notifications
You must be signed in to change notification settings - Fork 1
/
Cwd.h
40 lines (34 loc) · 976 Bytes
/
Cwd.h
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
/// \file
/// Declaration of the Cwd class.
/// <p>
/// Copyright (c) 2015 Ross Tyler.
/// This file may be copied under the terms of the
/// GNU Lesser General Public License (LGPL).
/// See COPYING file for details.
#ifndef Cwd_h
#define Cwd_h
#include <string>
#include "Synchronizable.h"
/// A Cwd object changes the current working directory on construction
/// and restores it on destruction.
class Cwd {
protected:
char * path;
public:
Cwd(char const * path) throw();
~Cwd() throw();
};
/// The CwdSynchronized class has one Cwd that is shared/synchronized
/// between any/all instances in the process so/as
/// there is only one notion of a "current directory" in the whole process.
class CwdSynchronized {
protected:
static Synchronizable<boost::mutex> synchronizable;
static Cwd * cwd;
static std::string path;
static unsigned count;
public:
CwdSynchronized(char const * path) throw();
~CwdSynchronized() throw();
};
#endif