14b169a6bSchristos /* gdb_file_up, an RAII wrapper around FILE. 2*5ba1f45fSchristos Copyright (C) 2021-2024 Free Software Foundation, Inc. 34b169a6bSchristos 44b169a6bSchristos This file is part of GDB. 54b169a6bSchristos 64b169a6bSchristos This program is free software; you can redistribute it and/or modify 74b169a6bSchristos it under the terms of the GNU General Public License as published by 84b169a6bSchristos the Free Software Foundation; either version 3 of the License, or 94b169a6bSchristos (at your option) any later version. 104b169a6bSchristos 114b169a6bSchristos This program is distributed in the hope that it will be useful, 124b169a6bSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of 134b169a6bSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 144b169a6bSchristos GNU General Public License for more details. 154b169a6bSchristos 164b169a6bSchristos You should have received a copy of the GNU General Public License 174b169a6bSchristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 184b169a6bSchristos 194b169a6bSchristos #ifndef GDBSUPPORT_GDB_FILE 204b169a6bSchristos #define GDBSUPPORT_GDB_FILE 214b169a6bSchristos 224b169a6bSchristos #include <memory> 234b169a6bSchristos #include <stdio.h> 244b169a6bSchristos 254b169a6bSchristos struct gdb_file_deleter 264b169a6bSchristos { 274b169a6bSchristos void operator() (FILE *file) const 284b169a6bSchristos { 294b169a6bSchristos fclose (file); 304b169a6bSchristos } 314b169a6bSchristos }; 324b169a6bSchristos 334b169a6bSchristos /* A unique pointer to a FILE. */ 344b169a6bSchristos 354b169a6bSchristos typedef std::unique_ptr<FILE, gdb_file_deleter> gdb_file_up; 364b169a6bSchristos 374b169a6bSchristos #endif 38