// disk.h // // by John D. de Boer // File Manager interface routines typedef struct { char *buff; // read/write buffer in heap bool writ, // file is opened for writing repl; // file is replacing another file SInt64 mark, // offset in buffer of next character to be read or written to pass; // number of characters passed so far in either reading or writing //short path; // File Manager reference number SInt16 forkref; // Fork reference number FSRef fsref, // File System Reference of file temp; // File System Reference of file being replaced } file; // Utility bool samefile(const FSRef *A, const FSRef *B); bool relfsref(const FSRef *A, const char *Path, FSRef *B); // Creating, opening, and closing files void iohalt(OSErr ERROR); void ioerror(OSErr ERROR); //bool openpathfile(const char *Path, const char *Name, bool Write, file *F); bool saveas(const char *Title, const char *Name, OSType Creator, OSType Type, file *F); bool createfile(FSRef *Dir, const char *Name, OSType Creator, OSType Type, file *F); bool openreplacement(file *Old, file *F); bool openexistingfile(OSType Type, file *F); bool openfile(FSRef *FSR, file *F); //bool openfile(short VOL, long DIR, const char *Name, file *F); //static bool finishreplacing(file *F); bool closefile(file *F); // Selecting a folder. The code for this is in select.c and select.rsrc, not disk.c // bool selectfolder(const char *S, short *VOL, long *DIR); // Basic file manipulation void setpath(file *F); void allocatebytes(file *F, long LEN); string filename(file *F); long filelength(file *F); long bytespassed(file *F); void writebytes(const void *P, long N); void readbytes(const void *P, long N); // Determining allocation for standard structures #define lengthofhandle(H) lengthofvoidhandle((void **)(H)) ulong lengthofstring(const char *S); ulong lengthofpointer(const void *P); ulong lengthofvoidhandle(void **H); // Writing standard structures #define writehandle(H) writevoidhandle((void **)(H)) void writechar(char C); void writeshort(short S); void writelong(long L); void writestring(const char *S); void writepointer(const void *P); void writevoidhandle(void **H); // Reading standard structures char readchar(void); short readshort(void); long readlong(void); string readstring(void); void *readpointer(void); void **readhandle(void); // PICTs /*ulong lengthofpict(PicHandle PH); void writepict(PicHandle PH); PicHandle readpict(void);*/ // Writing and reading miscellaneous data structures void writetext(const char *S, char Delim); void writetextold(string S, char Delim); void writefig(long N, char Delim); char readchar(void); long readnum(void); string readtext(void); int readuline(char *Buf, int MAX); void *newbytes(long N); // Reading entire files without the buffer string filetocharpointer(void); char **filetocharhandle(void); // File registry typedef struct { short num; // number of files currently loaded FSRef ***files; // a list of files that have already been read } filelist; void initfilelist(filelist *L); void purgefilelist(filelist *L); void addfiletolist(filelist *L, const FSRef *F); bool fileinlist(const filelist *L, const FSRef *F);