htils
1
A small set of utilities for C programming.
Toggle main menu visibility
Loading...
Searching...
No Matches
file.h
Go to the documentation of this file.
1
#ifndef HTILS_FILE_H
2
#define HTILS_FILE_H
3
4
/***********************************/
5
6
#include <stdio.h>
7
#include <sys/stat.h>
8
9
#include <
htils/arena.h
>
10
#include <
htils/basictypes.h
>
11
#include <
htils/string.h
>
12
15
#if defined(_WIN32)
16
#include <windows.h>
17
18
#define fileno _fileno
19
#define stat _stat64
20
#define fstat _fstati64
21
#endif
22
23
/***********************************/
24
54
u64
file_size_stream
(FILE *stream);
55
56
//
57
//
58
//
59
73
u64
file_size
(
const
string
*path);
74
75
//
76
//
77
//
78
98
string
*
read_file_from_stream
(
arena_t
*
arena
, FILE *stream);
99
100
//
101
//
102
//
103
119
string
*
read_file
(
arena_t
*
arena
,
const
string
*path);
120
121
//
122
//
123
//
124
146
string
*
read_file_from_stream_bytes
(
arena_t
*
arena
, FILE *stream,
147
const
u64
bytes);
148
149
//
150
//
151
//
152
171
string
*
read_file_bytes
(
arena_t
*
arena
,
const
string
*path,
const
u64
bytes);
172
173
//
174
//
175
//
176
197
u64
write_to_file_stream
(FILE *stream,
const
string
*contents);
198
199
//
200
//
201
//
202
218
u64
write_to_file
(
const
string
*path,
const
string
*contents);
219
220
//
221
//
222
//
223
246
u64
write_to_file_stream_bytes
(FILE *stream,
const
string
*contents,
247
const
u64
bytes);
248
249
//
250
//
251
//
252
271
u64
write_to_file_bytes
(
const
string
*path,
const
string
*contents,
272
const
u64
bytes);
273
274
#endif
// !HTILS_FILE_H
arena.h
arena_t
struct arena arena_t
An atomic arena.
basictypes.h
u64
uint64_t u64
Definition
basictypes.h:22
read_file_from_stream
string * read_file_from_stream(arena_t *arena, FILE *stream)
Reads the contents of a file from stream into a string.
Definition
file.c:37
read_file_bytes
string * read_file_bytes(arena_t *arena, const string *path, const u64 bytes)
Read bytes from a file path to string.
Definition
file.c:78
file_size_stream
u64 file_size_stream(FILE *stream)
Gets the size of a file from a file stream.
Definition
file.c:12
file_size
u64 file_size(const string *path)
Gets the size of a file at path.
Definition
file.c:23
write_to_file
u64 write_to_file(const string *path, const string *contents)
Write contents to file path.
Definition
file.c:104
read_file_from_stream_bytes
string * read_file_from_stream_bytes(arena_t *arena, FILE *stream, const u64 bytes)
Read bytes from file stream to string.
Definition
file.c:64
write_to_file_stream
u64 write_to_file_stream(FILE *stream, const string *contents)
Write contents to file stream.
Definition
file.c:93
read_file
string * read_file(arena_t *arena, const string *path)
Reads the contents of a file at path into a string.
Definition
file.c:50
write_to_file_bytes
u64 write_to_file_bytes(const string *path, const string *contents, const u64 bytes)
Write bytes from contents to a file at path.
Definition
file.c:132
write_to_file_stream_bytes
u64 write_to_file_stream_bytes(FILE *stream, const string *contents, const u64 bytes)
Write bytes from contents to stream.
Definition
file.c:119
string.h
arena
An atomic arena.
Definition
arena.h:45
include
htils
file.h
Generated by
1.17.0