2009-11-13 13:45:49 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2011-01-30 15:05:38 +00:00
|
|
|
#ifndef _PACKAGE__HPKG__FD_CLOSER_H_
|
|
|
|
#define _PACKAGE__HPKG__FD_CLOSER_H_
|
2009-11-13 13:45:49 +00:00
|
|
|
|
|
|
|
|
2011-01-27 23:17:03 +00:00
|
|
|
namespace BPackageKit {
|
|
|
|
|
2011-01-30 15:05:38 +00:00
|
|
|
namespace BHPKG {
|
2011-01-27 23:17:03 +00:00
|
|
|
|
|
|
|
|
2009-11-13 13:45:49 +00:00
|
|
|
struct FDCloser {
|
|
|
|
FDCloser(int fd)
|
|
|
|
:
|
|
|
|
fFD(fd)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~FDCloser()
|
|
|
|
{
|
|
|
|
if (fFD >= 0)
|
|
|
|
close(fFD);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int fFD;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-30 15:05:38 +00:00
|
|
|
} // namespace BHPKG
|
2011-01-27 23:17:03 +00:00
|
|
|
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
|
|
|
2011-01-30 15:05:38 +00:00
|
|
|
#endif // _PACKAGE__HPKG__FD_CLOSER_H_
|