home *** CD-ROM | disk | FTP | other *** search
/ Dream 57 / Amiga_Dream_57.iso / Amiga / Programmation / c / Outils / Edition / ASAPUpd.lha / FileHandle.h next >
Encoding:
C/C++ Source or Header  |  1998-06-19  |  8.8 KB  |  230 lines

  1. /*****************************************************************************
  2.  *                                                                           *
  3.  * ASAP - Amiga Software Authoring Platform                                  *
  4.  *                                                                           *
  5.  * Written by Laurie Perrin                                                  *
  6.  *                                                                           *
  7.  * AFileHandle wrapper class                                                 *
  8.  *                                                                           *
  9.  *****************************************************************************/
  10.  
  11. #ifndef ASAP_FileHandle_H
  12. #define ASAP_FileHandle_H
  13.  
  14. #include <New.h>
  15.  
  16. extern "C"
  17. {
  18.  #include <Proto/DOS.h>
  19. }
  20.  
  21. class AFileLock;
  22.  
  23. class AFileHandle : private FileHandle
  24. {
  25.  public:
  26. // inline void operator -> () { return (AFileHandle *) BADDR(this); }
  27. // inline AFileHandle& void operator * () { return *(AFileHandle *) BADDR(this); }
  28. // inline AFileHandle * void operator & () { return (AFileHandle *) MKBADDR(this); }
  29.  inline LONG Close();
  30.  inline void operator delete(void *);
  31.  inline AFileLock * DupLockFromFH();
  32.  inline BOOL ExamineFH(FileInfoBlock * fib);
  33.  inline LONG FGetC();
  34.  inline STRPTR FGets(STRPTR buf, unsigned long buflen);
  35.  inline LONG FPrintf(STRPTR format, LONG arg1 = 0, ...);
  36.  inline LONG FPutC(long ch);
  37.  inline LONG FPuts(STRPTR str);
  38.  inline LONG FRead(APTR block, unsigned long blocklen, unsigned long number);
  39.  inline LONG FWrite(APTR block, unsigned long blocklen, unsigned long number);
  40.  inline void FWritef(STRPTR format, LONG = 0, ...);
  41.  inline LONG Flush();
  42.  inline BPTR InternalLoadSeg(BPTR table, LONG * funcarray, LONG * stack);
  43.  inline BOOL IsInteractive();
  44.  inline BOOL LockRecord(unsigned long offset, unsigned long length, unsigned long mode, unsigned long timeout);
  45.  inline LONG NameFromFH(STRPTR buffer, long len);
  46.  inline static AFileHandle * Open(const char * name, long accessMode);
  47.  inline void * operator new(size_t, const char * name, long accessMode);
  48.  inline AFileLock * ParentOfFH();
  49.  inline LONG Read(APTR buffer, long length);
  50.  inline LONG Seek(long position, long offset);
  51.  inline AFileHandle * SelectInput();
  52.  inline AFileHandle * SelectOutput();
  53.  inline LONG SetFileSize(long pos, long mode);
  54.  inline LONG SetMode(long mode);
  55.  inline LONG SetVBuf(STRPTR buff, long type, long size);
  56.  inline LONG UnGetC(long character);
  57.  inline BOOL UnLockRecord(unsigned long offset, unsigned long length);
  58.  inline LONG VFPrintf(STRPTR format, APTR argarray);
  59.  inline void VFWritef(STRPTR format, LONG * argarray);
  60.  inline LONG WaitForChar(long timeout);
  61.  inline LONG Write(APTR buffer, long length);
  62. };
  63. //----------------------------------------------------------------------------
  64. LONG AFileHandle::Close ()
  65. {
  66.  return ::Close((BPTR) this);
  67. }
  68. //----------------------------------------------------------------------------
  69. void AFileHandle::operator delete (void *file)
  70. {
  71.  ((AFileHandle *) file)->Close();
  72. }
  73. //----------------------------------------------------------------------------
  74. AFileLock * AFileHandle::DupLockFromFH ()
  75. {
  76.  return (AFileLock *) ::DupLockFromFH((BPTR) this);
  77. }
  78. //----------------------------------------------------------------------------
  79. BOOL AFileHandle::ExamineFH (FileInfoBlock * fib)
  80. {
  81.  return ::ExamineFH((BPTR) this, fib);
  82. }
  83. //----------------------------------------------------------------------------
  84. LONG AFileHandle::FGetC ()
  85. {
  86.  return ::FGetC((BPTR) this);
  87. }
  88. //----------------------------------------------------------------------------
  89. STRPTR AFileHandle::FGets (STRPTR buf, unsigned long buflen)
  90. {
  91.  return ::FGets((BPTR) this, buf, buflen);
  92. }
  93. //----------------------------------------------------------------------------
  94. LONG AFileHandle::FPrintf (STRPTR format, LONG arg1, ...)
  95. {
  96.  return AFileHandle::VFPrintf(format, &arg1);
  97. }
  98. //----------------------------------------------------------------------------
  99. LONG AFileHandle::FPutC (long ch)
  100. {
  101.  return ::FPutC((BPTR) this, ch);
  102. }
  103. //----------------------------------------------------------------------------
  104. LONG AFileHandle::FPuts (STRPTR str)
  105. {
  106.  return ::FPuts((BPTR) this, str);
  107. }
  108. //----------------------------------------------------------------------------
  109. LONG AFileHandle::FRead (APTR block, unsigned long blocklen, unsigned long number)
  110. {
  111.  return ::FRead((BPTR) this, block, blocklen, number);
  112. }
  113. //----------------------------------------------------------------------------
  114. LONG AFileHandle::FWrite (APTR block, unsigned long blocklen, unsigned long number)
  115. {
  116.  return ::FWrite((BPTR) this, block, blocklen, number);
  117. }
  118. //----------------------------------------------------------------------------
  119. void AFileHandle::FWritef (STRPTR format, LONG arg1, ...)
  120. {
  121.  AFileHandle::VFWritef(format, &arg1);
  122. }
  123. //----------------------------------------------------------------------------
  124. LONG AFileHandle::Flush ()
  125. {
  126.  return ::Flush((BPTR) this);
  127. }
  128. //----------------------------------------------------------------------------
  129. BPTR AFileHandle::InternalLoadSeg (BPTR table, LONG * funcarray, LONG * stack)
  130. {
  131.  return ::InternalLoadSeg((BPTR) this, table, funcarray, stack);
  132. }
  133. //----------------------------------------------------------------------------
  134. BOOL AFileHandle::IsInteractive ()
  135. {
  136.  return (BOOL) ::IsInteractive((BPTR) this);
  137. }
  138. //----------------------------------------------------------------------------
  139. BOOL AFileHandle::LockRecord (unsigned long offset, unsigned long length, unsigned long mode, unsigned long timeout)
  140. {
  141.  return ::LockRecord((BPTR) this, offset, length, mode, timeout);
  142. }
  143. //----------------------------------------------------------------------------
  144. LONG AFileHandle::NameFromFH (STRPTR buffer, long len)
  145. {
  146.  return ::NameFromFH((BPTR) this, buffer, len);
  147. }
  148. //----------------------------------------------------------------------------
  149. AFileHandle * AFileHandle::Open (const char * name, long accessMode)
  150. {
  151.  return (AFileHandle *) ::Open((STRPTR) name, accessMode);
  152. }
  153. //----------------------------------------------------------------------------
  154. void * AFileHandle::operator new (size_t, const char * name, long accessMode)
  155. {
  156.  return AFileHandle::Open((STRPTR) name, accessMode);
  157. }
  158. //----------------------------------------------------------------------------
  159. AFileLock * AFileHandle::ParentOfFH ()
  160. {
  161.  return (AFileLock *) ::ParentOfFH((BPTR) this);
  162. }
  163. //----------------------------------------------------------------------------
  164. LONG AFileHandle::Read (APTR buffer, long length)
  165. {
  166.  return ::Read((BPTR) this, buffer, length);
  167. }
  168. //----------------------------------------------------------------------------
  169. LONG AFileHandle::Seek (long position, long offset)
  170. {
  171.  return ::Seek((BPTR) this, position, offset);
  172. }
  173. //----------------------------------------------------------------------------
  174. AFileHandle * AFileHandle::SelectInput ()
  175. {
  176.  return (AFileHandle *) ::SelectInput((BPTR) this);
  177. }
  178. //----------------------------------------------------------------------------
  179. AFileHandle * AFileHandle::SelectOutput ()
  180. {
  181.  return (AFileHandle *) ::SelectOutput((BPTR) this);
  182. }
  183. //----------------------------------------------------------------------------
  184. LONG AFileHandle::SetFileSize (long pos, long mode)
  185. {
  186.  return ::SetFileSize((BPTR) this, pos, mode);
  187. }
  188. //----------------------------------------------------------------------------
  189. LONG AFileHandle::SetMode (long mode)
  190. {
  191.  return ::SetMode((BPTR) this, mode);
  192. }
  193. //----------------------------------------------------------------------------
  194. LONG AFileHandle::SetVBuf (STRPTR buff, long type, long size)
  195. {
  196.  return ::SetVBuf((BPTR) this, buff, type, size);
  197. }
  198. //----------------------------------------------------------------------------
  199. LONG AFileHandle::UnGetC (long character)
  200. {
  201.  return ::UnGetC((BPTR) this, character);
  202. }
  203. //----------------------------------------------------------------------------
  204. BOOL AFileHandle::UnLockRecord (unsigned long offset, unsigned long length)
  205. {
  206.  return ::UnLockRecord((BPTR) this, offset, length);
  207. }
  208. //----------------------------------------------------------------------------
  209. LONG AFileHandle::VFPrintf (STRPTR format, APTR argarray)
  210. {
  211.  return ::VFPrintf((BPTR) this, format, argarray);
  212. }
  213. //----------------------------------------------------------------------------
  214. void AFileHandle::VFWritef (STRPTR format, LONG * argarray)
  215. {
  216.  ::VFWritef((BPTR) this, format, argarray);
  217. }
  218. //----------------------------------------------------------------------------
  219. LONG AFileHandle::WaitForChar (long timeout)
  220. {
  221.  return ::WaitForChar((BPTR) this, timeout);
  222. }
  223. //----------------------------------------------------------------------------
  224. LONG AFileHandle::Write (APTR buffer, long length)
  225. {
  226.  return ::Write((BPTR) this, buffer, length);
  227. }
  228.  
  229. #endif
  230.