Stimfit @PACKAGE_VERSION@
Loading...
Searching...
No Matches
FileIO.hpp
Go to the documentation of this file.
1//***********************************************************************************************
2//
3// Copyright (c) 1993-1997 Axon Instruments.
4// All rights reserved.
5// Permission is granted to freely to use, modify and copy the code in this file.
6//
7//***********************************************************************************************
8//
9// MODULE: FileIO.HPP
10// PURPOSE: Contains the class definition for the CFileIO class, a simple wrapper
11// around the WIN32 file I/O API.
12//
13
14#ifndef INC_FileIO_HPP
15#define INC_FileIO_HPP
16
17#include "axodefn.h"
19#include "./../AxAbfFio32/abffiles.h" // ABF file I/O API and error codes.
20#include "./../AxAbfFio32/csynch.hpp" // Virtual synch array object
21
22class CFileIO
23{
24 private: // Member variables and constants.
25 TCHAR m_szFileName[_MAX_PATH]; // The complete filename of the file
26 FILEHANDLE m_hFileHandle; // The DOS file handle for data file
27 DWORD m_dwLastError; // Error number for last error.
28
29 private: // Prevent default copy constructor and operator=()
30 CFileIO(const CFileIO &FI);
31 const CFileIO &operator=(const CFileIO &FI);
32
33 private: // Internal functions.
34 BOOL SeekFailure(DWORD dwOffset);
35
36 public:
39#if !defined(_MSC_VER)
41#endif
43
44 BOOL Create(LPCTSTR szFileName, BOOL bReadOnly, DWORD dwAttributes=FILE_ATTRIBUTE_NORMAL);
45 BOOL CreateEx(LPCTSTR szFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
46 DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes);
48 /* BOOL IsOpen() const;
49
50 BOOL Write(const void *pvBuffer, DWORD dwSizeInBytes, DWORD *pdwBytesWritten=NULL);
51 */ BOOL Read(void *pvBuffer, DWORD dwSizeInBytes, DWORD *pdwBytesRead=NULL);
52 BOOL Seek(LONGLONG lOffset, UINT uFlag=FILE_BEGIN, LONGLONG *plNewOffset=NULL);
53 /* BOOL GetCurrentPosition(LONGLONG *plCurrentPosition);
54 BOOL Flush();
55
56 BOOL SetEndOfFile();
58 /*
59 BOOL GetFileTime( LPFILETIME pCreationTime, LPFILETIME pLastAccessTime=NULL,
60 LPFILETIME pLastWriteTime=NULL);
61 BOOL SetFileTime( LPFILETIME pCreationTime, LPFILETIME pLastAccessTime=NULL,
62 LPFILETIME pLastWriteTime=NULL);
63
64 BOOL GetFileInformation(LPBY_HANDLE_FILE_INFORMATION lpFileInformation);
65
66 */ void SetFileHandle(FILEHANDLE hFile);
68 LPCTSTR GetFileName() const;
70 /*
71 BOOL Duplicate(CFileIO *pNewFile, BOOL bInheritable=TRUE);
72 BOOL SetInheritable(BOOL bInheritable=TRUE);
73 */
77
78};
79
80//===============================================================================================
81// FUNCTION: GetFileName
82// PURPOSE: Get the name of the file.
83//
85{
86 // MEMBERASSERT();
87 return m_szFileName;
88}
89
90//===============================================================================================
91// FUNCTION: GetFileHandle
92// PURPOSE: Returns the file handle opened in the object.
93//
95{
96 // MEMBERASSERT();
97 return m_hFileHandle;
98}
99#if 0
100
101//===============================================================================================
102// FUNCTION: IsOpen
103// PURPOSE: Returns TRUE if an open file handle is held.
104//
105inline BOOL CFileIO::IsOpen() const
106{
107 MEMBERASSERT();
108 return (m_hFileHandle != INVALID_HANDLE_VALUE);
109}
110
111//===============================================================================================
112// FUNCTION: SetEndOfFile
113// PURPOSE: Truncates the file to the current position.
114//
115inline BOOL CFileIO::SetEndOfFile()
116{
117 MEMBERASSERT();
118 return ::SetEndOfFile(m_hFileHandle) ? TRUE : SetLastError();
119}
120
121#endif
122//===============================================================================================
123// CLASS: CFileIO_NoClose
124// PURPOSE: Derivation of CFileIO that does not close the file when destroyed.
125// NOTES: N.B. Not polymorphic -- do NOT use through base class pointer.
126//
127class CFileIO_NoClose : public CFileIO
128{
129 private: // Prevent default copy constructor and operator=()
130 CFileIO_NoClose(const CFileIO_NoClose &FI);
131 const CFileIO_NoClose &operator=(const CFileIO_NoClose &FI);
132
133 public:
136};
137#if 0
138//===============================================================================================
139// CLASS: CFileIO_Pipe
140// PURPOSE: Class wrapper around a Win32 pipe.
141// NOTES: Poor encapsulation as internal CFileIO objects are returned.
142//
143class CFileIO_Pipe
144{
145 private:
146 CFileIO m_ReadPipe;
147 CFileIO m_WritePipe;
148
149 private: // Prevent default copy constructor and operator=()
150 CFileIO_Pipe(const CFileIO_Pipe &);
151 const CFileIO_Pipe &operator=(const CFileIO_Pipe &);
152
153 public:
154 CFileIO_Pipe();
155 ~CFileIO_Pipe();
156
157 BOOL Create(BOOL bInheritable);
158 CFileIO *GetReadPipe();
159 CFileIO *GetWritePipe();
160};
161#endif
162
163#endif // INC_FileIO_HPP
#define MEMBERASSERT()
Definition axodebug.h:140
CFileIO_NoClose(HANDLE hFile)
DWORD GetLastError() const
BOOL SetLastError()
LPCTSTR GetFileName() const
Definition FileIO.hpp:84
BOOL Read(void *pvBuffer, DWORD dwSizeInBytes, DWORD *pdwBytesRead=NULL)
BOOL SetLastError(DWORD nError)
FILEHANDLE Release()
void SetFileHandle(FILEHANDLE hFile)
CFileIO(HANDLE hFile)
BOOL Create(LPCTSTR szFileName, BOOL bReadOnly, DWORD dwAttributes=FILE_ATTRIBUTE_NORMAL)
CFileIO(FILEHANDLE hFile)
BOOL Seek(LONGLONG lOffset, UINT uFlag=FILE_BEGIN, LONGLONG *plNewOffset=NULL)
LONGLONG GetFileSize()
FILEHANDLE GetFileHandle() const
Definition FileIO.hpp:94
BOOL CreateEx(LPCTSTR szFileName, DWORD dwDesiredAccess, DWORD dwShareMode, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes)
BOOL Close()
char TCHAR
Definition unix.h:123
int BOOL
Definition unix.h:49
#define FILE_BEGIN
Definition unix.h:153
unsigned int UINT
Definition unix.h:47
#define INVALID_HANDLE_VALUE
Definition unix.h:32
FILE * FILEHANDLE
Definition unix.h:38
#define _MAX_PATH
Definition unix.h:188
void * HANDLE
Definition unix.h:136
#define TRUE
Definition unix.h:171
unsigned ABFLONG DWORD
Definition unix.h:45
#define FILE_ATTRIBUTE_NORMAL
Definition unix.h:156
LPCSTR LPCTSTR
Definition unix.h:130
long long LONGLONG
Definition unix.h:143