mirror of
https://github.com/NixOS/nix.git
synced 2025-11-15 06:52:43 +01:00
* Some wrapper classes to ensure that file descriptors / directory
handles are closed when they go out of scope.
This commit is contained in:
parent
c62433751d
commit
4a8948b7a6
6 changed files with 123 additions and 56 deletions
|
|
@ -11,29 +11,6 @@
|
|||
#include "globals.hh"
|
||||
|
||||
|
||||
class AutoDelete
|
||||
{
|
||||
string path;
|
||||
bool del;
|
||||
public:
|
||||
|
||||
AutoDelete(const string & p) : path(p)
|
||||
{
|
||||
del = true;
|
||||
}
|
||||
|
||||
~AutoDelete()
|
||||
{
|
||||
if (del) deletePath(path);
|
||||
}
|
||||
|
||||
void cancel()
|
||||
{
|
||||
del = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static string pathNullDevice = "/dev/null";
|
||||
|
||||
|
||||
|
|
@ -140,5 +117,3 @@ void runProgram(const string & program,
|
|||
throw Error("unable to build package");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue