xref: /netbsd-src/external/gpl3/gdb.old/dist/gdbsupport/gdb_file.h (revision 6881a4007f077b54e5f51159c52b9b25f57deb0d)
1*6881a400Schristos /* gdb_file_up, an RAII wrapper around FILE.
2*6881a400Schristos    Copyright (C) 2021-2023 Free Software Foundation, Inc.
3*6881a400Schristos 
4*6881a400Schristos    This file is part of GDB.
5*6881a400Schristos 
6*6881a400Schristos    This program is free software; you can redistribute it and/or modify
7*6881a400Schristos    it under the terms of the GNU General Public License as published by
8*6881a400Schristos    the Free Software Foundation; either version 3 of the License, or
9*6881a400Schristos    (at your option) any later version.
10*6881a400Schristos 
11*6881a400Schristos    This program is distributed in the hope that it will be useful,
12*6881a400Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*6881a400Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*6881a400Schristos    GNU General Public License for more details.
15*6881a400Schristos 
16*6881a400Schristos    You should have received a copy of the GNU General Public License
17*6881a400Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18*6881a400Schristos 
19*6881a400Schristos #ifndef GDBSUPPORT_GDB_FILE
20*6881a400Schristos #define GDBSUPPORT_GDB_FILE
21*6881a400Schristos 
22*6881a400Schristos #include <memory>
23*6881a400Schristos #include <stdio.h>
24*6881a400Schristos 
25*6881a400Schristos struct gdb_file_deleter
26*6881a400Schristos {
27*6881a400Schristos   void operator() (FILE *file) const
28*6881a400Schristos   {
29*6881a400Schristos     fclose (file);
30*6881a400Schristos   }
31*6881a400Schristos };
32*6881a400Schristos 
33*6881a400Schristos /* A unique pointer to a FILE.  */
34*6881a400Schristos 
35*6881a400Schristos typedef std::unique_ptr<FILE, gdb_file_deleter> gdb_file_up;
36*6881a400Schristos 
37*6881a400Schristos #endif
38