1#ifndef _file_hpp_INCLUDED
2#define _file_hpp_INCLUDED
18#define cadical_putc_unlocked putc
19#define cadical_getc_unlocked getc
22#define cadical_putc_unlocked putc_unlocked
23#define cadical_getc_unlocked getc_unlocked
25#define cadical_putc_unlocked putc
26#define cadical_getc_unlocked getc
45#if !defined(CADICAL_QUIET) || !defined(CADICAL_NDEBUG)
56 File (
Internal *,
bool,
int,
int, FILE *,
const char *);
58 static FILE *open_file (
Internal *,
const char *path,
const char *
mode);
59 static FILE *read_file (
Internal *,
const char *path);
60 static FILE *write_file (
Internal *,
const char *path);
62 static void split_str (
const char *, std::vector<char *> &);
63 static void delete_str_vector (std::vector<char *> &);
65 static FILE *open_pipe (
Internal *,
const char *fmt,
const char *path,
67 static FILE *read_pipe (
Internal *,
const char *fmt,
const int *sig,
70 static FILE *write_pipe (
Internal *,
const char *fmt,
const char *path,
76 static bool exists (
const char *path);
77 static bool writable (
const char *path);
78 static size_t size (
const char *path);
84 static bool match (
Internal *,
const char *path,
const int *sig);
126 bool put (
unsigned char ch) {
134 bool put (
const char *s) {
135 for (
const char *
p = s; *
p;
p++)
145 else if (
lit == -2147483648) {
147 return put (
"-2147483648");
150 int i =
sizeof buffer;
153 unsigned idx = abs (
lit);
156 buffer[--i] =
'0' + idx % 10;
159 if (
lit < 0 && !
put (
'-'))
161 return put (buffer + i);
169 else if (l == INT64_MIN) {
171 return put (
"-9223372036854775808");
174 int i =
sizeof buffer;
177 uint64_t k = l < 0 ? -l : l;
180 buffer[--i] =
'0' + k % 10;
183 if (l < 0 && !
put (
'-'))
185 return put (buffer + i);
195 int i =
sizeof buffer;
199 buffer[--i] =
'0' + l % 10;
202 return put (buffer + i);
206 const char *
name ()
const {
return _name; }
207 uint64_t
lineno ()
const {
return _lineno; }
208 uint64_t
bytes ()
const {
return _bytes; }
213 void close (
bool print =
false);
#define ABC_NAMESPACE_CXX_HEADER_START
#define ABC_NAMESPACE_CXX_HEADER_END
#define CADICAL_assert(ignore)
const char * name() const
static bool match(Internal *, const char *path, const int *sig)
bool put(unsigned char ch)
static char * find_program(const char *prg)
void close(bool print=false)
static bool exists(const char *path)
static File * write(Internal *, FILE *, const char *name)
void connect_internal(Internal *i)
static File * read(Internal *, FILE *f, const char *name)
static size_t size(const char *path)
static bool writable(const char *path)
#define cadical_getc_unlocked
#define cadical_putc_unlocked