https://codeberg.org/interpeer/vessel.git
Tip revision: 5c7a39214ce9b5396b7aafb9d576b159b57ef04a authored by Jens Finkhaeuser on 09 January 2024, 12:10:19 UTC
(void) and () have different meanings in C
(void) and () have different meanings in C
Tip revision: 5c7a392
file_deleter.h
/**
* This file is part of vessel.
*
* Author(s): Jens Finkhaeuser <jens@finkhaeuser.de>
*
* Copyright (c) 2022 Interpeer gUG (haftungsbeschränkt).
*
* SPDX-License-Identifier: GPL-3.0-only
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef TEST_FILE_DELETER_H
#define TEST_FILE_DELETER_H
#include <string>
#include <unistd.h>
namespace test {
struct file_deleter
{
std::string m_fname;
inline file_deleter(std::string fname)
: m_fname{fname}
{
}
inline ~file_deleter()
{
if (m_fname.empty()) {
return;
}
unlink(m_fname.c_str());
}
};
} // namespace test
#endif // guard