CCOleStream Class Reference

Represents an IStream within an OLE Structured Storage. Uses the custom iostream class costream for its implementation. More...

#include <ccfile.h>

Inheritance diagram for CCOleStream:

CCStreamFile CCLexFile CCFile CCObject SimpleCCObject CCOleAccusoftStream List of all members.

Public Member Functions

 CCOleStream (IStream *pIStream=0, UINT32 bufferSize=(1024), BOOL ErrorReporting=TRUE, BOOL ExceptionThrowing=FALSE)
 Constructs a CCOleStream attached to the given IStream, or not.
 CCOleStream (PathName path, INT32 fileMode, INT32 fileAccess=filebuf::_Openprot, UINT32 bufferSize=(1024), BOOL ErrorReporting=TRUE, BOOL ExceptionThrowing=FALSE)
virtual BOOL isOpen () const
 Returns the status of this file object.
virtual INT32 Size ()
virtual BOOL setMode (INT32 fileMode=filebuf::text)
 Set this CCOleStream's mode, either text or binary. Does nothing, as CCOleStreams only support binary mode.
virtual BOOL open_file (PathName fPath, INT32 fileMode, INT32 fileAccess=filebuf::_Openprot)
virtual BOOL attach (IStream *pIstream)
 Attaches this CCOleStream to the IStream.
virtual void close ()
 Closes this CCOleStream. You must call attach with another IStream before you perform I/O on it again.

Protected Member Functions

costream & GetCoStream () const
 I don't know why but things seem to be going awire! Basically, camelot has developed a severe BUG; and doing the following: edit-copy, file-exit; causes it to throw a wobobley! The only thing that I managed to find that was responsible for causing this was the inline function CCOleStream::GetCoStream(). The original implementation of this function should be fine (and had been fine for about four years); but (like most things) it seems to have stopped working overnight - in the form of a nasty access violation! Anyway, I've made the function not-inline; and it seems to have solved the bug (and the fellow line on 4021). All I can hazard a guess at is that the compiler was getting things wrong !!!!

Detailed Description

Represents an IStream within an OLE Structured Storage. Uses the custom iostream class costream for its implementation.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/8/96
See also:
IStream; IStorage; costream; costreambuf; CCStreamFile; CCDiskFile; CCLexFile

Definition at line 661 of file ccfile.h.


Constructor & Destructor Documentation

CCOleStream::CCOleStream IStream *  pIStream = 0,
UINT32  cbSize = (1024),
BOOL  fReport = TRUE,
BOOL  fThrow = FALSE
 

Constructs a CCOleStream attached to the given IStream, or not.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/8/96
Parameters:
pIStream - the IStream interface to attach to this CCOleStream. This [INPUTS] will be used for all I/O.

Definition at line 4055 of file ccfile.cpp.

04056   : CCStreamFile(new costream(pIStream), cbSize, fReport, fThrow)
04057 {
04058     // Work out the access mode, if any.
04059 //  TRACEUSER( "JustinF", _T("In CCOleStream::CCOleStream\n"));
04060 //  IOFile = NULL;
04061 
04062     if (isOpen()) GetCoStream().get_access_mode(&ModeOfFile, 0);
04063 }

CCOleStream::CCOleStream PathName  path,
INT32  fileMode,
INT32  fileAccess = filebuf::_Openprot,
UINT32  bufferSize = (1024),
BOOL  ErrorReporting = TRUE,
BOOL  ExceptionThrowing = FALSE
 

Definition at line 4110 of file ccfile.cpp.

04112   : CCStreamFile(new costream(path.GetPath(), nMode, nAccess), cbSize, fReport, fThrow)
04113 {
04114 //  TRACEUSER( "JustinF", _T("In CCOleStream::CCOleStream\n"));
04115     ModeOfFile = nMode;
04116 }


Member Function Documentation

BOOL CCOleStream::attach IStream *  pIStream  )  [virtual]
 

Attaches this CCOleStream to the IStream.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/8/96
Parameters:
pIStream - the IStream interface to connect to this CCOleStream. This [INPUTS] will be used for all subsequent I/O.
Returns:
TRUE if successful, FALSE if not.

Definition at line 4204 of file ccfile.cpp.

04205 {
04206 //  TRACEUSER( "JustinF", _T("In CCOleStream::attach\n"));
04207     return SUCCEEDED(GetCoStream().attach(pIStream));
04208 }

void CCOleStream::close  )  [virtual]
 

Closes this CCOleStream. You must call attach with another IStream before you perform I/O on it again.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/8/96
See also:
CCOleStream::attach

Reimplemented from CCStreamFile.

Definition at line 4222 of file ccfile.cpp.

04223 {
04224 //  TRACEUSER( "JustinF", _T("In CCOleStream::close\n"));
04225     GetCoStream().close();
04226 }

costream & CCOleStream::GetCoStream  )  const [protected]
 

I don't know why but things seem to be going awire! Basically, camelot has developed a severe BUG; and doing the following: edit-copy, file-exit; causes it to throw a wobobley! The only thing that I managed to find that was responsible for causing this was the inline function CCOleStream::GetCoStream(). The original implementation of this function should be fine (and had been fine for about four years); but (like most things) it seems to have stopped working overnight - in the form of a nasty access violation! Anyway, I've made the function not-inline; and it seems to have solved the bug (and the fellow line on 4021). All I can hazard a guess at is that the compiler was getting things wrong !!!!

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/11/77
Parameters:
- [INPUTS]

Definition at line 4086 of file ccfile.cpp.

04087 {
04088     return ((costream&) *IOFile);
04089 }

BOOL CCOleStream::isOpen  )  const [virtual]
 

Returns the status of this file object.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/8/96
Returns:
TRUE if this CCOleStream is currently open, ie. attached to an IStream.

Reimplemented from CCStreamFile.

Definition at line 4129 of file ccfile.cpp.

04130 {
04131     // the inline function GetCoStream seems to have been fouling this up ....
04132     // so we are doing this for now ....
04133     
04134     const costream& cs = (const costream&) *IOFile;
04135     return CCStreamFile::isOpen() && cs.is_open();
04136 
04137     // instead of this ....
04138     
04139     //return CCStreamFile::isOpen() && GetCoStream().is_open();
04140 }

BOOL CCOleStream::open_file PathName  fPath,
INT32  fileMode,
INT32  fileAccess = filebuf::_Openprot
[virtual]
 

Definition at line 4158 of file ccfile.cpp.

04159 {
04160     // Sanity check.
04161 //  TRACEUSER( "JustinF", _T("In CCOleStream::open_file(%s)\n"), (LPCTSTR) path.GetPath());
04162     ERROR2IF(!path.IsValid(), FALSE, "Invalid PathName in CCOleStream::open_file");
04163     ERROR2IF(!IsInited(), FALSE, "CCOleStream not initiallised in CCOleStream::open_file");
04164 
04165     // Nuke any existing open error states that might exist
04166     IOFile->clear(IOFile->goodbit);
04167 
04168     // If we are not opening this file for writing then set the ios::nocreate
04169     // flag due to a bug in the iostream classes (but not if the ios::out flag is specified
04170     // as well. If this is not set we can not open files on read-only mounts shared by windows 95.
04171     if ((fileMode & ios::in) && !(fileMode & ios::out)) fileMode |= ios::nocreate;
04172 
04173     // Set the sharing mode if the default was passed.
04174     if (fileAccess == filebuf::openprot) fileAccess = costream::sh_read | costream::sh_write;
04175 
04176     // Note the current opening mode.
04177     ModeOfFile = fileMode;
04178 
04179     // Try to open the stream.
04180     if (FAILED(GetCoStream().open_file(path.GetPath(), fileMode | ios::binary, fileAccess)))
04181     {
04182         // TO DO: fix this to be a more appropriate error message.
04183         GotError(_R(IDE_OPEN_ERROR));
04184         return FALSE;
04185     }
04186 
04187     // Success.
04188     return TRUE;
04189 }

BOOL CCOleStream::setMode INT32  fileMode = filebuf::text  )  [virtual]
 

Set this CCOleStream's mode, either text or binary. Does nothing, as CCOleStreams only support binary mode.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/8/96
Returns:
TRUE

Reimplemented from CCStreamFile.

Definition at line 4272 of file ccfile.cpp.

04273 {
04274     TRACEUSER( "JustinF", _T("CCOleStream::setMode called - is this OK?\n") );
04275     return TRUE;
04276 }

INT32 CCOleStream::Size  )  [virtual]
 

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/8/96
Returns:
The size of this IStream, in bytes.

Reimplemented from CCStreamFile.

Definition at line 4238 of file ccfile.cpp.

04239 {
04240     // Size of what???
04241     if (!isOpen())
04242     {
04243         ERROR3("CCOleStream::Size called when stream is not open");
04244         return 0;
04245     }
04246     
04247     // Go direct to the IStream for this.
04248     STATSTG statstg;
04249     HRESULT hr = ((IStream*) GetCoStream())->Stat(&statstg, STATFLAG_NONAME);
04250     if (FAILED(hr))
04251     {
04252         ERROR3("CCOleStream::Size failed - why?");
04253         return 0;
04254     }
04255 
04256     // We can only return the lower 31 bits (doh!)
04257     return (INT32) statstg.cbSize.LowPart;
04258 }


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:52:08 2007 for Camelot by  doxygen 1.4.4