00001
00002
00003
00004
00005 #ifndef __WINDOWS_FILEIO_H
00006 #define __WINDOWS_FILEIO_H
00007
00008 #include "Types.h"
00009
00010 namespace NWindows {
00011 namespace NFile {
00012 namespace NIO {
00013
00014 struct CByHandleFileInfo
00015 {
00016 DWORD Attributes;
00017 FILETIME CreationTime;
00018 FILETIME LastAccessTime;
00019 FILETIME LastWriteTime;
00020 DWORD VolumeSerialNumber;
00021 UInt64 Size;
00022 DWORD NumberOfLinks;
00023 UInt64 FileIndex;
00024 };
00025
00026 class CFileBase
00027 {
00028 protected:
00029 bool _fileIsOpen;
00030 HANDLE _handle;
00031 bool Create(LPCTSTR fileName, DWORD desiredAccess,
00032 DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
00033 #ifndef _UNICODE
00034 bool Create(LPCWSTR fileName, DWORD desiredAccess,
00035 DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
00036 #endif
00037
00038 public:
00039 CFileBase(): _fileIsOpen(false){};
00040 virtual ~CFileBase();
00041
00042 virtual bool Close();
00043
00044 bool GetPosition(UInt64 &position) const;
00045 bool GetLength(UInt64 &length) const;
00046
00047 bool Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const;
00048 bool Seek(UInt64 position, UInt64 &newPosition);
00049 bool SeekToBegin();
00050 bool SeekToEnd(UInt64 &newPosition);
00051
00052 bool GetFileInformation(CByHandleFileInfo &fileInfo) const;
00053 };
00054
00055 class CInFile: public CFileBase
00056 {
00057 public:
00058 bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
00059 bool Open(LPCTSTR fileName);
00060 #ifndef _UNICODE
00061 bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
00062 bool Open(LPCWSTR fileName);
00063 #endif
00064 bool ReadPart(void *data, UInt32 size, UInt32 &processedSize);
00065 bool Read(void *data, UInt32 size, UInt32 &processedSize);
00066 };
00067
00068 class COutFile: public CFileBase
00069 {
00070
00071 public:
00072
00073 bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
00074 bool Open(LPCTSTR fileName, DWORD creationDisposition);
00075 bool Create(LPCTSTR fileName, bool createAlways);
00076
00077 #ifndef _UNICODE
00078 bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
00079 bool Open(LPCWSTR fileName, DWORD creationDisposition);
00080 bool Create(LPCWSTR fileName, bool createAlways);
00081 #endif
00082
00083
00084
00085 bool SetTime(const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime);
00086 bool SetLastWriteTime(const FILETIME *lastWriteTime);
00087 bool WritePart(const void *data, UInt32 size, UInt32 &processedSize);
00088 bool Write(const void *data, UInt32 size, UInt32 &processedSize);
00089 bool SetEndOfFile();
00090 bool SetLength(UInt64 length);
00091 };
00092
00093 }}}
00094
00095 #endif