home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / OWLINC.PAK / FILEDOC.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  3KB  |  81 lines

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