This file is indexed.

/usr/include/gromacs/utility/file.h is in libgromacs-dev 5.1.2-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
/*
 * This file is part of the GROMACS molecular simulation package.
 *
 * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 * and including many others, as listed in the AUTHORS file in the
 * top-level source directory and at http://www.gromacs.org.
 *
 * GROMACS is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1
 * of the License, or (at your option) any later version.
 *
 * GROMACS 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with GROMACS; if not, see
 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
 *
 * If you want to redistribute modifications to GROMACS, please
 * consider that scientific software is very special. Version
 * control is crucial - bugs must be traceable. We will be happy to
 * consider code for inclusion in the official distribution, but
 * derived work must not be called official GROMACS. Details are found
 * in the README & COPYING files - if they are missing, get the
 * official version at http://www.gromacs.org.
 *
 * To help us fund GROMACS development, we humbly ask that you cite
 * the research papers on the package. Check out http://www.gromacs.org.
 */
/*! \file
 * \brief
 * Declares gmx::File.
 *
 * \author Teemu Murtola <teemu.murtola@gmail.com>
 * \inpublicapi
 * \ingroup module_utility
 */
#ifndef GMX_UTILITY_FILE_H
#define GMX_UTILITY_FILE_H

#include <cstdio>

#include <string>

#include "gromacs/utility/classhelpers.h"

namespace gmx
{

class File;

/*! \brief
 * Parameters for creating a File object.
 *
 * This class (mostly) replaces the ability to return a File object from a
 * function (since File is not copyable): returning a FileInitializer instead
 * allows the caller to construct the File object.
 *
 * \inpublicapi
 * \ingroup module_utility
 */
class FileInitializer
{
    public:
        /*! \brief
         * Creates the initializer with given parameters.
         *
         * The passed strings must remain valid until the initializer is used
         * to construct a File object.
         */
        FileInitializer(const char *filename, const char *mode)
            : filename_(filename), mode_(mode)
        {
        }

    private:
        const char *filename_;
        const char *mode_;

        /*! \brief
         * Needed to allow access to the parameters without otherwise
         * unnecessary accessors.
         */
        friend class File;
};

/*! \brief
 * Basic file object.
 *
 * This class provides basic file I/O functionality and uses exceptions
 * (FileIOError) for error reporting.
 *
 * \inpublicapi
 * \ingroup module_utility
 */
class File
{
    public:
        /*! \brief
         * Opens a file and returns a `FILE` handle.
         *
         * \param[in] filename  Path of the file to open.
         * \param[in] mode      Mode to open the file in (for fopen()).
         * \throws    FileIOError on any I/O error.
         *
         * Instead of returning `NULL` on errors, throws an exception with
         * additional details (including the file name and `errno`).
         */
        static FILE *openRawHandle(const char *filename, const char *mode);
        //! \copydoc openRawHandle(const char *, const char *)
        static FILE *openRawHandle(const std::string &filename, const char *mode);
        /*! \brief
         * Creates a file object and opens a file.
         *
         * \param[in] filename  Path of the file to open.
         * \param[in] mode      Mode to open the file in (for fopen()).
         * \throws    std::bad_alloc if out of memory.
         * \throws    FileIOError on any I/O error.
         *
         * \see open(const char *, const char *)
         */
        File(const char *filename, const char *mode);
        //! \copydoc File(const char *, const char *)
        File(const std::string &filename, const char *mode);
        /*! \brief
         * Creates a file object and opens a file.
         *
         * \param[in] initializer  Parameters to open the file.
         * \throws    std::bad_alloc if out of memory.
         * \throws    FileIOError on any I/O error.
         */
        File(const FileInitializer &initializer);
        /*! \brief
         * Destroys the file object.
         *
         * If the file is still open, it is closed.
         * Any error conditions will be ignored.
         */
        ~File();

        /*! \brief
         * Opens a file.
         *
         * \param[in] filename  Path of the file to open.
         * \param[in] mode      Mode to open the file in (for fopen()).
         * \throws    FileIOError on any I/O error.
         *
         * The file object must not be open.
         */
        void open(const char *filename, const char *mode);
        //! \copydoc open(const char *, const char *)
        void open(const std::string &filename, const char *mode);
        /*! \brief
         * Closes the file object.
         *
         * \throws  FileIOError on any I/O error.
         *
         * The file must be open.
         */
        void close();

        /*! \brief
         * Returns whether the file is an interactive terminal.
         *
         * Only works on Unix, otherwise always returns true.
         * It only makes sense to call this for File::standardInput() and
         * friends.
         *
         * Thie file must be open.
         * Does not throw.
         */
        bool isInteractive() const;
        /*! \brief
         * Returns a file handle for interfacing with C functions.
         *
         * The file must be open.
         * Does not throw.
         */
        FILE *handle();

        /*! \brief
         * Reads given number of bytes from the file.
         *
         * \param[out] buffer  Pointer to buffer that receives the bytes.
         * \param[in]  bytes   Number of bytes to read.
         * \throws     FileIOError on any I/O error.
         *
         * The file must be open.
         */
        void readBytes(void *buffer, size_t bytes);
        /*! \brief
         * Reads a single line from the file.
         *
         * \param[out] line    String to receive the line.
         * \returns    false if nothing was read because the file ended.
         * \throws     std::bad_alloc if out of memory.
         * \throws     FileIOError on any I/O error.
         *
         * On error or when false is returned, \p line will be empty.
         * Trailing space will be removed from the line.
         * To loop over all lines in the file, use:
         * \code
           std::string line;
           while (file.readLine(&line))
           {
               // ...
           }
           \endcode
         */
        bool readLine(std::string *line);
        /*! \brief
         * Reads a single line from the file.
         *
         * \param[out] line    String to receive the line.
         * \returns    false if nothing was read because the file ended.
         * \throws     std::bad_alloc if out of memory.
         * \throws     FileIOError on any I/O error.
         *
         * On error or when false is returned, \p line will be empty.
         * Works as readLine(), except that terminating newline will be present
         * in \p line if it was present in the file.
         *
         * \see readLine()
         */
        bool readLineWithTrailingSpace(std::string *line);

        /*! \brief
         * Writes a string to the file.
         *
         * \param[in]  str  String to write.
         * \throws     FileIOError on any I/O error.
         *
         * The file must be open.
         */
        void writeString(const char *str);
        //! \copydoc writeString(const char *)
        void writeString(const std::string &str) { writeString(str.c_str()); }
        /*! \brief
         * Writes a line to the file.
         *
         * \param[in]  line  Line to write.
         * \throws     FileIOError on any I/O error.
         *
         * If \p line does not end in a newline, one newline is appended.
         * Otherwise, works as writeString().
         *
         * The file must be open.
         */
        void writeLine(const char *line);
        //! \copydoc writeLine(const char *)
        void writeLine(const std::string &line) { writeLine(line.c_str()); }
        /*! \brief
         * Writes a newline to the file.
         *
         * \throws     FileIOError on any I/O error.
         */
        void writeLine();

        /*! \brief
         * Checks whether a file exists and is a regular file.
         *
         * \param[in] filename  Path to the file to check.
         * \returns   true if \p filename exists and is accessible.
         *
         * Does not throw.
         */
        static bool exists(const char *filename);
        //! \copydoc exists(const char *)
        static bool exists(const std::string &filename);

        /*! \brief
         * Returns a File object for accessing stdin.
         *
         * \throws    std::bad_alloc if out of memory (only on first call).
         */
        static File &standardInput();
        /*! \brief
         * Returns a File object for accessing stdout.
         *
         * \throws    std::bad_alloc if out of memory (only on first call).
         */
        static File &standardOutput();
        /*! \brief
         * Returns a File object for accessing stderr.
         *
         * \throws    std::bad_alloc if out of memory (only on first call).
         */
        static File &standardError();

        /*! \brief
         * Reads contents of a file to a std::string.
         *
         * \param[in] filename  Name of the file to read.
         * \returns   The contents of \p filename.
         * \throws    std::bad_alloc if out of memory.
         * \throws    FileIOError on any I/O error.
         */
        static std::string readToString(const char *filename);
        //! \copydoc readToString(const char *)
        static std::string readToString(const std::string &filename);
        /*! \brief
         * Convenience method for writing a file from a string in a single call.
         *
         * \param[in] filename  Name of the file to read.
         * \param[in] text      String to write to \p filename.
         * \throws    FileIOError on any I/O error.
         *
         * If \p filename exists, it is overwritten.
         */
        static void writeFileFromString(const std::string &filename,
                                        const std::string &text);

    private:
        /*! \brief
         * Initialize file object from an existing file handle.
         *
         * \param[in]  fp     %File handle to use (may be NULL).
         * \param[in]  bClose Whether this object should close its file handle.
         * \throws     std::bad_alloc if out of memory.
         *
         * Used internally to implement standardOutput() and standardError().
         */
        File(FILE *fp, bool bClose);

        class Impl;

        PrivateImplPointer<Impl> impl_;
};

} // namespace gmx

#endif