ocfile.h
Go to the documentation of this file.00001 #ifndef ocfile_h
00002 #define ocfile_h
00003
00004 #include <OS/string.h>
00005 class File;
00006 class FileChooser;
00007
00008 class OcFile {
00009 public:
00010 OcFile();
00011 virtual ~OcFile();
00012 boolean open(const char* filename, const char* type);
00013 void set_name(const char* s);
00014 const char* get_name() {return filename_.string();}
00015 const char* dir();
00016 void close();
00017 void print(const char* s) {fprintf(file(), "%s", s);}
00018 FILE* file();
00019 boolean is_open() { return file_ ? true : false;}
00020 boolean eof();
00021 void flush() { if (file_) { fflush(file_); }}
00022 boolean mktemp();
00023 boolean unlink();
00024 void file_chooser_style(char* type, char* path,
00025 char* banner=nil, char* filter=nil,
00026 char* accept=nil, char* cancel=nil);
00027 boolean file_chooser_popup();
00028 #ifdef WIN32
00029 void binary_mode();
00030 #endif
00031 private:
00032 FileChooser* fc_;
00033 enum { N, R, W, A};
00034 int chooser_type_;
00035 CopyString filename_;
00036 CopyString dirname_;
00037 FILE* file_;
00038 #ifdef WIN32
00039 boolean binary_;
00040 char mode_[3];
00041 #endif
00042 };
00043
00044 #ifdef WIN32
00045 #define BinaryMode(ocfile) ocfile->binary_mode();
00046 #else
00047 #define BinaryMode(ocfile)
00048 #endif
00049
00050 #endif