Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e57c4f
commit 202d8d8
Showing
8 changed files
with
53 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef _TEST_SUPPORT_H_ | ||
#define _TEST_SUPPORT_H_ | ||
|
||
#include <sys/stat.h> | ||
#include <sys/types.h> | ||
#include <iostream> | ||
#include <string> | ||
#include <exception> | ||
#include <cerrno> | ||
#include <cstring> | ||
|
||
namespace Test { | ||
|
||
using namespace std; | ||
|
||
class TempDir { | ||
private: | ||
string name; | ||
public: | ||
TempDir(const string &name) { | ||
this->name = name; | ||
if (mkdir(name.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0) { | ||
int e = errno; | ||
cerr << "Cannot create directory '" << name << "': " << | ||
strerror(e) <<" (" << e << ")" << endl; | ||
throw exception(); | ||
} | ||
} | ||
|
||
~TempDir() { | ||
string command("rm -rf \""); | ||
command.append(name); | ||
command.append("\""); | ||
system(command.c_str()); | ||
} | ||
}; | ||
|
||
} // namespace Test | ||
|
||
#endif /* _TEST_SUPPORT_H_ */ |