|
// CJMemFile.h: interface for the CCJMemFile class.
//
// Copyright � 1999 Maxallion
// mailto:XFile@maxallion.8m.com
// ICQ# 32304418
//
// CCJMemFile - Extended Memory File - Beta - w/o a lot of error checking
// - Is used like a normal CFile or CStdioFile or CMemFile object
// - String Functions : ReadString, WriteString
// - Loads physical files into memory on creation and saves them back to disk on destruction
// - Can duplicate itself to other CFile derived objects
// - Has a Search function
// - can be read-accessed like an array
//
// OVERLOADED OPERATORS:
// = Imports from another file or sets file Position
// += Appends another file
// [] reads a byte like an array
//
/////////////////////////////////////////////////////////////////////////////
/****************************************************************************
*
* $Date: 24/05/02 13:52 $
* $Revision: 2 $
* $Archive: /Projects/AddIns/ResOrg/CJLibrary/Include/CJMemFile.h $
*
* $History: CJMemFile.h $
*
* ***************** Version 2 *****************
* User: Andy Date: 24/05/02 Time: 13:52
* Updated in $/Projects/AddIns/ResOrg/CJLibrary/Include
* Modifications for compatibility with Visual Studio.NET
*
* ***************** Version 1 *****************
* User: Kirk Stowell Date: 10/24/99 Time: 3:01a
* Created in $/CodeJock/Include
* Initial creation.
*
***************************************************************************/
/////////////////////////////////////////////////////////////////////////////
#ifndef __CJMEMFILE_H__
#define __CJMEMFILE_H__
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class _CJX_EXT_CLASS CCJMemFile : public CMemFile
{
private:
CFileException* m_pError;
CFile m_File;
UINT m_uiOpenFlags;
bool m_bOpen;
public:
CCJMemFile( UINT nGrowBytes = 1024 );
CCJMemFile( BYTE* lpBuffer, UINT nBufferSize, UINT nGrowBytes = 0 );
CCJMemFile(LPCTSTR lpstFilename, UINT uiOpenFlags);
virtual ~CCJMemFile();
protected:
// Load() loads the file into Memory
virtual bool Load();
// Save() saves the file to Disk
virtual bool Save();
// Import() imports the data of a CFile derived object (operator = )
virtual bool Import(CFile *fImp);
// Appends a CFile derived object to the file (operator += )
virtual bool Append(CFile *fApp);
public:
// Flush() saves the memory to disk
virtual void Flush();
// Open(...) opens and loads a physical File into memory
virtual bool Open(CString strFilename, UINT uiOpenFlags, CFileException *pError = NULL);
// Close() saves the contents of the memory to the disk and closes it.
virtual void Close();
// ReadString(...) reads a string
virtual BOOL ReadString(CString& rString);
// WriteString(...) appends a string
virtual void WriteString( LPCTSTR lpsz );
// Duplicate(...) Duplicates the CCJMemFile to a CFile derived class
virtual bool Duplicate(CFile *fDuplicate);
virtual bool Duplicate(CString strDup);
// Discard() discards all changes to file since Open() or last Flush()
virtual bool Discard();
// Insert(...) inserts any File and returns the length of actual copied bytes
#if _MSC_VER >= 1300 // VC 7.0 (.NET)
virtual ULONGLONG Insert(CFile* fSrc, LONGLONG dwSourcePos, LONGLONG dwDestPos, LONGLONG dwBytes);
virtual ULONGLONG Insert(CString strSrc, LONGLONG dwSourcePos, LONGLONG dwDestPos, LONGLONG dwBytes);
// Extract(...) Extracts bytes to a file and returns the length of actual copied bytes
virtual ULONGLONG Extract(CFile *fDest,LONGLONG dwStartPos, LONGLONG dwBytes);
virtual ULONGLONG Extract(CString strDest, LONGLONG dwStartPos, LONGLONG dwBytes);
#else // VC 5.0/6.0
virtual DWORD Insert(CFile* fSrc, DWORD dwSourcePos, DWORD dwDestPos, DWORD dwBytes);
virtual DWORD Insert(CString strSrc, DWORD dwSourcePos, DWORD dwDestPos, DWORD dwBytes);
// Extract(...) Extracts bytes to a file and returns the length of actual copied bytes
virtual DWORD Extract(CFile *fDest,DWORD dwStartPos, DWORD dwBytes);
virtual DWORD Extract(CString strDest, DWORD dwStartPos, DWORD dwBytes);
#endif
// Find(...) Finds data in the file
LONG FindData(void* pData, DWORD dwDataLen, LONG lStartPos);
// Overloaded Operators
public:
// Importing Operators
void operator =( CFile *fDup);
void operator =( CString strDup);
// Positioning
void operator =( DWORD dwFilePos);
// Appending operators
void operator +=( CFile *fApp);
void operator +=( CString strApp);
// Indexing Operators
BYTE operator [](DWORD dwFilePos);
};
#endif // !defined(__CJMEMFILE_H__)
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I haven't always written software for a living. When I graduated from Surrey University in 1989, it was with an Electronic Engineering degree, but unfortunately that never really gave me the opportunity to do anything particularly interesting (with the possible exception of designing
Darth Vader's Codpiece * for the UK Army in 1990).
* Also known as the Standard Army Bootswitch. But that's another story...
Since the opportunity arose to lead a software team developing C++ software for
Avionic Test Systems in 1996, I've not looked back. More recently I've been involved in the development of subsea acoustic navigation systems, digital TV broadcast systems, port security/tracking systems, and most recently software development tools with my own company,
Riverblade Ltd.
One of my personal specialities is IDE plug-in development.
ResOrg was my first attempt at a plug-in, but my day to day work is with
Visual Lint, an interactive code analysis tool environment with works within the Visual Studio and Eclipse IDEs or on build servers.
I love lots of things, but particularly music, photography and anything connected with history or engineering. I
despise ignorant, intolerant and obstructive people - and it shows...I can be a bolshy cow if you wind me up the wrong way...
I'm currently based 15 minutes walk from the beach in Bournemouth on the south coast of England. Since I moved here I've grown to love the place - even if it is full of grockles in Summer!