b2api
B2000++ API Reference Manual, VERSION 4.6
Loading...
Searching...
No Matches
tempdir.H
1
//------------------------------------------------------------------------
2
// tempdir.H --
3
//
4
// Providing a class to create a unique temporary directory.
5
// The directory is deleted again at the end of the lifetime of the
6
// object.
7
//
8
// written by Harald Klimach <harald.klimach@dlr.de>
9
//
10
// (c) 2024 Deutsches Zentrum für Luft- und Raumfahrt (DLR) e.V.
11
// Linder Höhe, 51147 Köln
12
//
13
// All Rights Reserved. Proprietary source code. The contents of
14
// this file may not be disclosed to third parties, copied or
15
// duplicated in any form, in whole or in part, without the prior
16
// written permission of SMR or DLR.
17
//
18
//------------------------------------------------------------------------
19
20
#ifndef TEMPDIR_H_
21
#define TEMPDIR_H_
22
#include <filesystem>
23
#include <string>
24
29
class
Tempdir
{
30
public
:
43
Tempdir
(std::string prefix,
unsigned
long
max_tries);
44
explicit
Tempdir
(std::string prefix) :
Tempdir
(prefix, 100) {}
45
explicit
Tempdir
() :
Tempdir
(
""
) {}
46
47
Tempdir
(
const
Tempdir
& other) =
delete
;
// Don't allow copy construction
48
Tempdir
(
Tempdir
&& other) {
49
dirpath = other.dirpath;
50
other.delete_dir =
false
;
51
}
52
Tempdir
& operator=(
const
Tempdir
& other) =
delete
;
// Don't allow copy assignment
53
Tempdir
& operator=(
Tempdir
&& other);
54
56
~Tempdir
();
57
59
std::filesystem::path
path
()
const
;
60
61
private
:
62
bool
delete_dir{
true
};
63
std::filesystem::path dirpath;
64
};
65
66
#endif
// TEMPDIR_H_
Tempdir
Definition
tempdir.H:29
Tempdir::~Tempdir
~Tempdir()
Destructor removes the created directory and its contents again.
Definition
tempdir.C:67
Tempdir::path
std::filesystem::path path() const
Get the path of the Tempdir directory in the filesystem.
Definition
tempdir.C:65
utils
tempdir.H
Generated by
1.9.8