00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __EDELIB_FILE_H__
00022 #define __EDELIB_FILE_H__
00023
00024 #include <stdio.h>
00025 #include "String.h"
00026
00027 EDELIB_NS_BEGIN
00028
00033 enum FileErrors {
00034 FILE_SUCCESS = 0,
00035 FILE_EACCESS,
00036 FILE_ENOENT,
00037 FILE_EMFILE,
00038 FILE_ENSPC,
00039 FILE_FLAG
00040 };
00041
00046 enum FileIOMode {
00047 FIO_READ = (1<<1),
00048 FIO_WRITE = (1<<2),
00049 FIO_APPEND = (1<<3),
00050 FIO_BINARY = (1<<4),
00051 FIO_TRUNC = (1<<5)
00052 };
00053
00074 class EDELIB_API File {
00075 private:
00076 FILE* fobj;
00077 char* fname;
00078 int fmode;
00079 int errcode;
00080 bool opened;
00081 bool alloc;
00082
00083 File(const File&);
00084 File& operator=(File&);
00085
00086 public:
00090 File();
00091
00098 File(const char* fname, int mode);
00099
00104 ~File();
00105
00112 bool open(const char* fname, int mode = FIO_READ);
00113
00119 void close(void);
00120
00127 const char* name(void) const;
00128
00134 bool eof(void);
00135
00141 int getch(void);
00142
00151 int read(void* buff, int typesz, int buffsz);
00152
00166 int readline(char* buff, int buffsz);
00167
00173 int putch(int c);
00174
00183 int write(const void* buff, int typesz, int buffsz);
00184
00192 int write(const char* buff, unsigned int buffsz);
00193
00197 int write(const char* buff);
00198
00204 int printf(const char* fmt, ...);
00205 };
00206
00212 EDELIB_API bool file_exists(const char* name) EDELIB_DEPRECATED;
00213
00219 EDELIB_API bool file_readable(const char* name) EDELIB_DEPRECATED;
00220
00226 EDELIB_API bool file_writeable(const char* name) EDELIB_DEPRECATED;
00227
00228
00234 EDELIB_API bool file_executable(const char* name) EDELIB_DEPRECATED;
00235
00245 EDELIB_API bool file_remove(const char* name);
00246
00266 EDELIB_API bool file_copy(const char* src, const char* dest, bool exact = false);
00267
00275 EDELIB_API bool file_rename(const char* from, const char* to);
00276
00294 EDELIB_API String file_path(const char* fname, bool skip_link = false);
00295
00296 EDELIB_NS_END
00297 #endif