view src/win32/7zip/7z/CPP/Windows/FileIO.h @ 5:8fe0c57e53d2

concentrating on lua first
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:39:40 -0600
parents f9f4f1b99eed
children
line wrap: on
line source
1 // Windows/FileIO.h
3 #ifndef __WINDOWS_FILEIO_H
4 #define __WINDOWS_FILEIO_H
6 #include "../Common/Types.h"
8 namespace NWindows {
9 namespace NFile {
10 namespace NIO {
12 struct CByHandleFileInfo
13 {
14 DWORD Attributes;
15 FILETIME CTime;
16 FILETIME ATime;
17 FILETIME MTime;
18 DWORD VolumeSerialNumber;
19 UInt64 Size;
20 DWORD NumberOfLinks;
21 UInt64 FileIndex;
22 };
24 class CFileBase
25 {
26 protected:
27 HANDLE _handle;
28 bool Create(LPCTSTR fileName, DWORD desiredAccess,
29 DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
30 #ifndef _UNICODE
31 bool Create(LPCWSTR fileName, DWORD desiredAccess,
32 DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
33 #endif
35 public:
36 CFileBase(): _handle(INVALID_HANDLE_VALUE){};
37 ~CFileBase();
39 bool Close();
41 bool GetPosition(UInt64 &position) const;
42 bool GetLength(UInt64 &length) const;
44 bool Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const;
45 bool Seek(UInt64 position, UInt64 &newPosition);
46 bool SeekToBegin();
47 bool SeekToEnd(UInt64 &newPosition);
49 bool GetFileInformation(CByHandleFileInfo &fileInfo) const;
50 };
52 class CInFile: public CFileBase
53 {
54 public:
55 bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
56 bool OpenShared(LPCTSTR fileName, bool shareForWrite);
57 bool Open(LPCTSTR fileName);
58 #ifndef _UNICODE
59 bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
60 bool OpenShared(LPCWSTR fileName, bool shareForWrite);
61 bool Open(LPCWSTR fileName);
62 #endif
63 bool ReadPart(void *data, UInt32 size, UInt32 &processedSize);
64 bool Read(void *data, UInt32 size, UInt32 &processedSize);
65 };
67 class COutFile: public CFileBase
68 {
69 // DWORD m_CreationDisposition;
70 public:
71 // COutFile(): m_CreationDisposition(CREATE_NEW){};
72 bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
73 bool Open(LPCTSTR fileName, DWORD creationDisposition);
74 bool Create(LPCTSTR fileName, bool createAlways);
76 #ifndef _UNICODE
77 bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
78 bool Open(LPCWSTR fileName, DWORD creationDisposition);
79 bool Create(LPCWSTR fileName, bool createAlways);
80 #endif
82 /*
83 void SetOpenCreationDisposition(DWORD creationDisposition)
84 { m_CreationDisposition = creationDisposition; }
85 void SetOpenCreationDispositionCreateAlways()
86 { m_CreationDisposition = CREATE_ALWAYS; }
87 */
89 bool SetTime(const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime);
90 bool SetMTime(const FILETIME *mTime);
91 bool WritePart(const void *data, UInt32 size, UInt32 &processedSize);
92 bool Write(const void *data, UInt32 size, UInt32 &processedSize);
93 bool SetEndOfFile();
94 bool SetLength(UInt64 length);
95 };
97 }}}
99 #endif