home *** CD-ROM | disk | FTP | other *** search
- #ifndef CPP_DOS_FILES_H
- #define CPP_DOS_FILES_H
-
- // Datei- und Lockklassen
- //
- // Autor: Jochen Becher
- //
- // Historie:
- // Version 1.0 am 18. Februar 94
-
- #ifndef DOS_DOS_H
- #include <dos/dos.h>
- #endif
-
- #ifndef DOS_DOSEXTENS_H
- #include <dos/dosextens.h>
- #endif
-
- #ifndef CPP_DOS_DOS_H
- #include <classes/dos/dos.h>
- #endif
-
- #ifndef CPP_UTILITY_TAGITEM_H
- #include <classes/utility/tagitem.h>
- #endif
-
- #ifndef CPP_EXEC_SHARE_H
- #include <classes/exec/share.h>
- #endif
-
- #ifndef CPP_DATASTRUCTURES_BUFFER_H
- #include <classes/datastructures/buffer.h>
- #endif
-
- #ifndef CPP_DATASTRUCTURES_STRING_H
- #include <classes/datastructures/string.h>
- #endif
-
- class FileInfoBlockC : public DosObjectC {
- public:
- FileInfoBlockC(struct TagItem *tags = NULL) throw (DosObjectX, MemoryX)
- : DosObjectC(DOS_FIB,tags) { };
- FileInfoBlockC(Tag tag1type, ...) throw (DosObjectX, MemoryX)
- : DosObjectC(DOS_FIB,(struct TagItem *) &tag1type) { };
- struct FileInfoBlock *object() const
- { return (struct FileInfoBlock *) DosObjectC::object(); };
- };
-
- class ExAllControlC : public DosObjectC {
- public:
- ExAllControlC(struct TagItem *tags = NULL) throw (DosObjectX, MemoryX)
- : DosObjectC(DOS_EXALLCONTROL,tags) { };
- ExAllControlC(Tag tag1type, ...) throw (DosObjectX, MemoryX)
- : DosObjectC(DOS_EXALLCONTROL,(struct TagItem *) &tag1type) { };
- struct ExAllControl *object() const
- { return (struct ExAllControl *) DosObjectC::object(); };
- };
-
- class InfoDataC : public DosObjectC {
- public:
- InfoDataC() throw (DosObjectX, MemoryX);
- ~InfoDataC();
- InfoDataC &operator= (const InfoDataC &);
- struct InfoData *object() const
- { return (struct InfoData *) DosObjectC::object(); };
- };
-
- class PathStringC : public StringC {
- public:
- PathStringC(LONG initsize) throw (MemoryX);
- PathStringC(const STRPTR = NULL) throw (MemoryX);
- PathStringC(const PathStringC &);
- ~PathStringC();
- PathStringC &operator= (const PathStringC &);
- STRPTR path() const { return (STRPTR) buffer.buffer(); }
- VOID setPath(STRPTR path) throw (MemoryX);
- VOID addPart(STRPTR add) throw (MemoryX);
- VOID addSuffix(STRPTR suffix) throw (MemoryX);
- STRPTR filePart() const;
- VOID cutBeforeFilePart();
- VOID cutBehindPathPart();
- VOID cutSuffix();
- };
-
- class FileLockC {
- public:
- FileLockC();
- FileLockC(const FileLockC &);
- FileLockC(BPTR lock);
- ~FileLockC();
- FileLockC &operator= (const FileLockC &);
- BPTR lock() const { return filelock; };
- BOOL isLocked() const { return filelock != NULL; };
- BOOL lock(STRPTR name, LONG mode);
- BOOL duplicate(FileLockC &fromLock);
- BOOL duplicate(class FileHandleC &fromHandle);
- VOID unlock();
- BOOL changeMode(ULONG mode);
- BOOL sameDevice(FileLockC &other) const;
- BOOL sameLock(FileLockC &other) const;
- BOOL nameOfLock(STRPTR buffer, LONG length) const;
- BOOL nameOfLock(PathStringC &) const;
- BOOL examine(struct FileInfoBlock *) const;
- BOOL examine(FileInfoBlockC &) const;
- BOOL info(struct InfoData *) const;
- BOOL info(InfoDataC &) const;
- static LONG ioErr();
- protected:
- BPTR filelock;
- };
-
- class DirLockC : public FileLockC {
- public:
- DirLockC();
- DirLockC(BPTR lock);
- BOOL create(STRPTR name);
- BOOL parentOf(FileLockC &lock);
- BOOL parentOf(class FileHandleC &handle);
- BOOL fromCurrent();
- BOOL fromBootvolume();
- BOOL fromProgramDir();
- BOOL exAll(struct ExAllControl *, APTR buffer, ULONG bufsize, ULONG type);
- BOOL exAll(ExAllControlC &, APTR buffer, ULONG bufsize, ULONG type);
- VOID exAllEnd(struct ExAllControl *, APTR buffer, ULONG bufsize, ULONG type);
- VOID exAllEnd(ExAllControlC &, APTR buffer, ULONG bufsize, ULONG type);
- BOOL exNext(struct FileInfoBlock *);
- BOOL exNext(FileInfoBlockC &);
- };
-
- class CurrentDirC {
- public:
- CurrentDirC();
- CurrentDirC(STRPTR name);
- ~CurrentDirC();
- BOOL makeCurrent(DirLockC &);
- private:
- CurrentDirC(const CurrentDirC &);
- CurrentDirC &operator = (const CurrentDirC &);
- BPTR filelock;
- };
-
- class FileHandleC {
- public:
- FileHandleC();
- FileHandleC(const FileHandleC &);
- virtual ~FileHandleC();
- FileHandleC &operator = (const FileHandleC &);
- BPTR handle() const { return filehandle; };
- BOOL open(STRPTR name, LONG mode);
- BOOL open(FileLockC &);
- virtual BOOL close();
- BOOL changeMode(ULONG mode);
- LONG read(APTR buffer, LONG length);
- LONG write(APTR buffer, LONG length);
- LONG seek(LONG position, LONG mode = OFFSET_BEGINNING);
- BOOL eof();
- LONG fGetC();
- BOOL fGets(STRPTR s, ULONG len);
- BOOL fPutC(ULONG c);
- BOOL fPuts(STRPTR s);
- ULONG fRead(APTR buffer, ULONG len, ULONG blocks);
- ULONG fWrite(APTR buffer, ULONG len, ULONG blocks);
- LONG fPrintF(STRPTR s, LONG *args = NULL);
- LONG fPrintF(STRPTR s, ...);
- VOID fWriteF(STRPTR s, LONG *args = NULL);
- VOID fWriteF(STRPTR s, ...);
- VOID unGetC(LONG c = -1);
- BOOL flush();
- BOOL setVBuf(APTR buffer, LONG mode, LONG bufsize);
- BOOL waitForChar(ULONG micros);
- BOOL isInteractive();
- BOOL nameOfHandle(STRPTR buffer, LONG length) const;
- BOOL nameOfHandle(PathStringC &) const;
- BOOL examine(struct FileInfoBlock *) const;
- BOOL examine(FileInfoBlockC &) const;
- LONG setSize(LONG offset, LONG mode);
- static LONG ioErr();
- protected:
- BPTR filehandle;
- FileInfoBlockC fib;
- };
-
- class InputHandleC : public FileHandleC {
- public:
- InputHandleC();
- ~InputHandleC();
- BOOL close();
- };
-
- class OutputHandleC : public FileHandleC {
- public:
- OutputHandleC();
- ~OutputHandleC();
- BOOL close();
- };
-
- #endif
-