Unicorn XML Toolkit
Version 1.50.00

Namespace Core
Class CFileStream

class CFileStream: public IStream {
public:
    enum {
        modeCreate = 0x01,
        modeNoTruncate = 0x02,
        modeRead = 0x04,
        modeReadWrite = 0x08,
        modeWrite = 0x10,
        typeText = 0x20,
        typeBinary = 0x40
        };
public:
    CFileStream();
    ~CFileStream();
public:
    bool Open(const WCHAR *pszFileName, int nOpenFlags);
    void Close();
public:
    int Read(BYTE *pBuf, int nCount);
    void Write(const BYTE *pBuf, int nCount);
    void SetPosition(long lOff, int nFrom);
    long GetPosition();
    };
typedef XInterface<CFileStream> XFileStream;

The file-based byte stream.

Since:
1.00.00
Version:
1.50.00
Author:
Alexey Gokhberg
Constructor/Destructor Summary
CFileStream ();
����������Constructs the file stream.
~CFileStream ();
����������Destroys the file stream.

Function Summary
bool Open (const WCHAR *pszFileName, int nOpenFlags);
����������Opens a file, associates it with this stream.
void Close ();
����������Closes the file associated with this stream.
int Read (BYTE *pBuf, int nCount);
����������Reads the specified number of bytes into the specified buffer from this stream.
void Write (const BYTE *pBuf, int nCount);
����������Writes the specified number of bytes from the specified buffer to this stream.
void SetPosition (long lOff, int nFrom);
����������Moves the file pointer to the specified position.
long GetPosition ();
����������Returns a current position of the file pointer.

Constructor/Destructor Detail

CFileStream

CFileStream();

Constructs the file stream.

~CFileStream

~CFileStream();

Destroys the file stream.

Function Detail

Open

bool Open(const WCHAR *pszFileName, int nOpenFlags);

Opens a file, associates it with this stream.

The file name and the set of bit flags must be specified as arguments of this function.

Allowed values of bit flags are specified by the anonymous enumeration declared in this class.

Parameters:
pszFileName - the file name
nOpenFlags - the set of flags
Returns:
true if the file was successfully open; false otherwise

Close

void Close();

Closes the file associated with this stream.

Read

int Read(BYTE *pBuf, int nCount);

Reads the specified number of bytes into the specified buffer from this stream.

The number of bytes actually read may be less than the number of bytes requested.

Parameters:
pBuf - the buffer to hold result
nCount - the number of bytes to read
Returns:
the number of bytes actually read; the negative integer if read error occured

Write

void Write(const BYTE *pBuf, int nCount);

Writes the specified number of bytes from the specified buffer to this stream.

Parameters:
pBuf - the buffer to write
nCount - the number of bytes to write

SetPosition

void SetPosition(long lOff, int nFrom);

Moves the file pointer to the specified position.

The file pointer is positioned relatively to the origin. The origin is specified using the origin code; allowed values are: IStream::begin for beginning of file, IStream::current for current position of the file pointer, and IStream::end for end of file.

Parameters:
lOff - the relative position
nFrom - the origin code

GetPosition

long GetPosition();

Returns a current position of the file pointer.

Returns:
the current position of the file pointer

Unicorn XML Toolkit
Version 1.50.00


This document was created using Unicorn DOC++.

Copyright 1999-2001 Unicorn Enterprises SA.
All Rights Reserved.