home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / ADDONINC.PAK / IVFILE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  3.0 KB  |  91 lines

  1. /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2.  
  3.     ivfile.h
  4.     Created: 11/13/95
  5.     Copyright (c) 1987, 1995 Borland International Inc.  All Rights Reserved.
  6.     $Header:   Y:\admin\bride\addon\deliver\interfac\ivfile.h_v   1.20   18 Nov 1996 11:30:12   JDOUGLAS  $
  7.     $Revision:   1.20  $
  8.  
  9.    IVirtualFile
  10.  
  11.     The IDE uses a virtual file system to hide the difference between  
  12.     files in edit buffers vs. files on disk. If a file is opened that is 
  13.     already in an edit buffer, the read (not write) methods of this interface 
  14.     will act on the file image in the edit buffer, otherwise they will act on the 
  15.     file on disk. Write methods always act on the file on disk. To write to an
  16.    edit buffer, you must use the IEditorServer interface.
  17.     
  18. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/    
  19.  
  20. #ifndef __IVFILE_H
  21. #define __IVFILE_H
  22.  
  23. #include <objbase.h>
  24. #include <ideaddon\ivfile.uid>
  25. #include <ideaddon\ipolystr.h>
  26. #include <ideaddon\common.h>
  27.  
  28. enum VFOpenMode {
  29.     VFOM_Read,
  30.     VFOM_Write,
  31.     VFOM_ReadWrite,
  32.     VFOM_Create
  33. };
  34.  
  35. //.............................................................................
  36. class IVirtualFile : public IUnknown {
  37.  public:
  38.     //
  39.     //    Init() sets the file name for subsequent method calls through this
  40.     // interface. This affects Open(), IsReadOnly(), Exists() and GetAge()
  41.    //
  42.     virtual void BCWADDON_CMETHOD Init( IPolyString * fileName ) = 0;
  43.     //
  44.     //    GetErrorCode() returns the file system error number of the last error.
  45.     //
  46.    //
  47.     virtual int BCWADDON_CMETHOD GetErrorCode() = 0;
  48.     //
  49.     //    IsReadOnly() and Exists() return the status of the file specified through
  50.     // SetName().
  51.     //
  52.     virtual BOOL BCWADDON_CMETHOD IsReadOnly() = 0;     
  53.     virtual BOOL BCWADDON_CMETHOD Exists() = 0;
  54.     //
  55.     //    Opens the file specified through Init(). Subsequent calls to Read(),
  56.     // Write(), Seek(), Close() and Delete() work with the file opened by
  57.     // this method.
  58.     //
  59.     virtual BOOL BCWADDON_CMETHOD Open( VFOpenMode mode = VFOM_ReadWrite ) = 0;
  60.     //
  61.     //    Read() returns the number of bytes read.
  62.     //
  63.     virtual int BCWADDON_CMETHOD Read( char * buffer, int len ) = 0;
  64.     //
  65.     //    Write() returns the number of bytes written.
  66.     //
  67.     virtual int BCWADDON_CMETHOD Write( char * buffer, int len ) = 0;
  68.     //
  69.     //    Seek() returns the offset from the beginning of the file.
  70.     //    Use the Windows API FILE_BEGIN, FILE_CURRENT, FILE_END origin flags.
  71.     // 
  72.     virtual int BCWADDON_CMETHOD Seek( int offset, int origin = FILE_BEGIN ) = 0;
  73.     //
  74.     //    Close() the file opened with Open(). This will automatically be called
  75.     // when this interface's refcount reaches 0.
  76.     //
  77.     virtual void BCWADDON_CMETHOD Close() = 0;
  78.     //
  79.     //    If a buffer is open on a file that is being Deleted, that buffer is 
  80.     // unaffected by the call to Delete(), but the file on disk is deleted.
  81.     //
  82.     virtual void BCWADDON_CMETHOD Delete() = 0;
  83.    
  84.    //
  85.    //    Return the age of the file.
  86.    //
  87.    virtual long BCWADDON_CMETHOD GetAge() = 0;
  88.    
  89. };
  90.  
  91. #endif