[ci] Test Tcl bindings for dragonfly/freebsd
[xapian.git] / xapian-applications / omega / loadfile.h
blob0029dd847a69472c57cd5e2b7241e85da2f08168
1 /** @file
2 * @brief load a file into a std::string.
3 */
4 /* Copyright (C) 2006,2010,2012,2018 Olly Betts
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef OMEGA_INCLUDED_LOADFILE_H
22 #define OMEGA_INCLUDED_LOADFILE_H
24 #include <string>
26 enum { NOCACHE = 0x1, NOATIME = 0x2 };
28 bool load_file_from_fd(int fd, std::string& output);
30 static inline bool
31 load_file_from_fd(int fd, size_t size_hint, std::string& output)
33 output.resize(0);
34 output.reserve(size_hint);
35 return load_file_from_fd(fd, output);
38 bool load_file(const std::string& file_name, size_t max_to_read, int flags,
39 std::string& output, bool* truncated);
41 inline bool
42 load_file(const std::string& file_name, size_t max_to_read, int flags,
43 std::string& output, bool& truncated)
45 return load_file(file_name, max_to_read, flags, output, &truncated);
48 inline bool
49 load_file(const std::string& file_name, std::string& output, int flags = 0)
51 return load_file(file_name, 0, flags, output, nullptr);
54 #endif // OMEGA_INCLUDED_LOADFILE_H