home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 19.ddi / OWLINC.PAK / FILEDOC.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  2.5 KB  |  79 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1993 by Borland International
  3. //   include\owl\filedoc.h
  4. //   Defines class TFileDocument
  5. //----------------------------------------------------------------------------
  6. #if !defined(__OWL_FILEDOC_H)
  7. #define __OWL_FILEDOC_H
  8.  
  9. #if !defined(__OWL_DOCVIEW_H)
  10.   #include "owl\docview.h"
  11. #endif
  12. #if !defined(__IOSTREAM_H)
  13.   #include <iostream.h>
  14. #endif
  15.  
  16. //
  17. //  class TFileDocument
  18. //  ----- -------------
  19. //
  20. class _OWLCLASS TFileDocument : public TDocument {
  21.   public:
  22.     enum {
  23.       PrevProperty = TDocument::NextProperty-1,
  24.       CreateTime,        // FILETIME
  25.       ModifyTime,        // FILETIME
  26.       AccessTime,        // FILETIME
  27.       StorageSize,       // unsigned long
  28.       FileHandle,        // platform file handle (HFILE if Windows)
  29.       NextProperty,
  30.     };
  31.  
  32.     TFileDocument(TDocument* parent = 0)
  33.                  : TDocument(parent), FHdl(HFILE_ERROR), InfoPresent(FALSE) {}
  34.    ~TFileDocument() {}
  35.  
  36.     // implement virtual methods of TDocument
  37.     //
  38.     BOOL        Open(int mode, LPCSTR path=0);
  39.     BOOL        Close();
  40.     TInStream*  InStream (int mode, LPCSTR strmId=0);
  41.     TOutStream* OutStream(int mode, LPCSTR strmId=0);
  42.     BOOL        Commit(BOOL force = FALSE);
  43.     BOOL        Revert(BOOL clear = FALSE);
  44.     BOOL        IsOpen() {return FHdl != HFILE_ERROR || TDocument::IsOpen();}
  45.  
  46.     int         FindProperty(const char far* name);  // return index
  47.     int         PropertyFlags(int index);
  48.     const char* PropertyName(int index);
  49.     int         PropertyCount() {return NextProperty - 1;}
  50.     int         GetProperty(int index, void far* dest, int textlen=0);
  51.     BOOL        SetProperty(int index, const void far* src);
  52.  
  53.     // additional methods for file document
  54.     //
  55.     BOOL        Open(HFILE fhdl);     // open on existing file handle
  56.  
  57.   protected:
  58.     HFILE FHdl;  // file handle if held open at the document level
  59.     HFILE OpenThisFile(int omode, LPCSTR name, streampos* pseekpos);
  60.     void  CloseThisFile(HFILE fhdl, int omode);
  61.     friend class _OWLCLASS_RTL TFileInStream;
  62.     friend class _OWLCLASS_RTL TFileOutStream;
  63.  
  64.   private:  // cached info for property access
  65.     BOOL          InfoPresent;
  66.     unsigned long FileLength;
  67. #if defined(__WIN32__)
  68.     FILETIME FileCreateTime;
  69.     FILETIME FileAccessTime;
  70.     FILETIME FileUpdateTime;
  71. #else
  72.     unsigned long FileTime;
  73. #endif
  74.  
  75.   DECLARE_STREAMABLE (_OWLCLASS, TFileDocument,1);
  76. };
  77.  
  78. #endif  // __OWL_FILEDOC_H
  79.