Debian Codegraph @

debian/patches/create_temp_dir

raw symbols SCIP
1 Descriptionscip-debian debian lmdbxx 0.9.14.1+git20160229.0b43ca8-1 lmdbxx/patches/create_temp_dir#Description.: create temporary directory
2 Use a unique temporary directory for the test, and clean it up when done.
3 Authorscip-debian debian lmdbxx 0.9.14.1+git20160229.0b43ca8-1 lmdbxx/patches/create_temp_dir#Author.: Hubert Chathi <[email protected]scip-debian . . . identity/`[email protected]`.>
4 Forwardedscip-debian debian lmdbxx 0.9.14.1+git20160229.0b43ca8-1 lmdbxx/patches/create_temp_dir#Forwarded.: No
5
6 ---
7
8 --- lmdbxx-0.9.14.1+git20160228.0b43ca8.orig/check.ccscip-debian debian lmdbxx 0.9.14.1+git20160229.0b43ca8-1 lmdbxx/upstream/`lmdbxx-0.9.14.1+git20160228.0b43ca8.orig/check.cc`:
9 +++ lmdbxx-0.9.14.1+git20160228.0b43ca8/check.ccscip-debian debian lmdbxx 0.9.14.1+git20160229.0b43ca8-1 lmdbxx/upstream/`lmdbxx-0.9.14.1+git20160228.0b43ca8/check.cc`:
10 @@ -2,6 +2,9 @@
11
12 #include <cstdio> /* for std::*printf() */
13 #include <cstdlib> /* for EXIT_FAILURE, EXIT_SUCCESS */
14 +#include <cerrno> /* for std::errno */
15 +#include <cstring> /* for std::error */
16 +#include <unistd.h> /* for unlink and rmdir */
17 #include <lmdb++.h>
18
19 int main() {
20 @@ -9,14 +12,27 @@ int main() {
21 /* Create the LMDB environment: */
22 auto env = lmdb::env::create();
23
24 + char tmpdir[] = "/tmp/check.XXXXXX";
25 + if (!mkdtemp(tmpdir)) {
26 + std::fprintf(stderr, "Unable to create temporary directory: %s\n", std::strerror(errno));
27 + return EXIT_FAILURE;
28 + }
29 /* Open the LMDB environment: */
30 - env.open("/tmp");
31 + env.open(tmpdir);
32
33 /* Begin the LMDB transaction: */
34 auto txn = lmdb::txn::begin(env);
35
36 // TODO
37
38 + /* clean up */
39 + char filename[30]; // enough room for tmpdir + filename
40 + std::sprintf(filename, "%s/data.mdb", tmpdir);
41 + unlink(filename);
42 + std::sprintf(filename, "%s/lock.mdb", tmpdir);
43 + unlink(filename);
44 + rmdir(tmpdir);
45 +
46 return EXIT_SUCCESS;
47 }
48 catch (const lmdb::error& error) {