24 #ifndef _UCOMMON_FILE_H_
25 #define _UCOMMON_FILE_H_
27 #ifndef _UCOMMON_CONFIG_H_
31 #ifndef _UCOMMON_PROTOCOLS_H_
35 #ifndef _UCOMMON_THREAD_H_
39 #ifndef _UCOMMON_STRING_H_
43 #ifndef _UCOMMON_MEMORY_H_
47 #ifndef _UCOMMON_FSYS_H_
78 typedef ::fpos_t bookmark_t;
96 file(
const char *path,
const char *mode,
size_t size = 2);
105 file(
const char *path,
char **argv,
const char *mode,
char **envp = NULL);
121 inline operator bool()
const {
129 inline bool operator !()
const {
133 inline operator FILE *()
const {
143 void open(
const char *path,
const char *mode,
size_t size = 2);
151 void open(
const char *path,
char **argv,
const char *mode,
char **envp = NULL);
171 bool good(
void)
const;
179 inline size_t put(
const void *data,
size_t size) {
180 return fp == NULL ? 0 : fwrite(data, 1, size, fp);
183 inline size_t get(
void *data,
size_t size) {
184 return fp == NULL ? 0 : fread(data, 1, size, fp);
187 inline int put(
char value) {
188 return fp == NULL ? EOF : fputc(value, fp);
191 inline int get(void) {
192 return fp == NULL ? EOF : fgetc(fp);
195 inline int push(
char value) {
196 return fp == NULL ? EOF : ungetc(value, fp);
199 inline int puts(
const char *data) {
200 return fp == NULL ? 0 : fputs(data, fp);
203 inline char *gets(
char *data,
size_t size) {
204 return fp == NULL ? NULL : fgets(data, (socksize_t)size, fp);
207 template<
typename T>
inline size_t read(T* data,
size_t count) {
208 return fp == NULL ? 0 : fread(data,
sizeof(T), count, fp);
211 template<
typename T>
inline size_t write(
const T* data,
size_t count) {
212 return fp == NULL ? 0 : fwrite(data,
sizeof(T), count, fp);
215 template<
typename T>
inline size_t read(T& data) {
216 return fp == NULL ? 0 : fread(data,
sizeof(T), 1, fp);
219 template<
typename T>
inline size_t write(
const T& data) {
220 return fp == NULL ? 0 : fwrite(data,
sizeof(T), 1, fp);
223 inline void get(bookmark_t& pos) {
228 inline void set(bookmark_t& pos) {
235 bool eof(
void)
const;
237 template<
typename T>
inline void offset(
long pos) {
239 fseek(fp,
sizeof(
const T) * pos, SEEK_CUR);
242 inline void seek(
long offset) {
244 fseek(fp, offset, SEEK_SET);
247 inline void move(
long offset) {
249 fseek(fp, offset, SEEK_CUR);
252 inline void append(
void) {
254 fseek(fp, 0l, SEEK_END);
257 inline void rewind(
void) {
262 inline void flush(
void) {
267 size_t printf(
const char *format, ...) __PRINTF(2, 3);
269 size_t scanf(const
char *format, ...) __SCANF(2, 3);
271 bool is_tty(
void) const;
273 inline FILE *operator*()
const {
A common string class and character string support functions.
Thread classes and sychronization objects.
Various miscellaneous platform specific headers and defines.
Thread-aware file system manipulation class.
Access standard files through character protocol.
file file_t
Convience type for file.
Private heaps, pools, and associations.
Common namespace for all ucommon objects.
void clear(void)
Clear error state.
Abstract interfaces and support.
Common character processing protocol.