other-licenses/7zstub/src/Windows/FileIO.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 CreationTime; 
    16   FILETIME LastAccessTime; 
    17   FILETIME LastWriteTime; 
    18   DWORD    VolumeSerialNumber; 
    19   UInt64   Size;
    20   DWORD    NumberOfLinks; 
    21   UInt64   FileIndex; 
    22 };
    24 class CFileBase
    25 {
    26 protected:
    27   bool _fileIsOpen;
    28   HANDLE _handle;
    29   bool Create(LPCTSTR fileName, DWORD desiredAccess,
    30       DWORD shareMode, DWORD creationDisposition,  DWORD flagsAndAttributes);
    31   #ifndef _UNICODE
    32   bool Create(LPCWSTR fileName, DWORD desiredAccess,
    33       DWORD shareMode, DWORD creationDisposition,  DWORD flagsAndAttributes);
    34   #endif
    36 public:
    37   CFileBase(): _fileIsOpen(false){};
    38   virtual ~CFileBase();
    40   virtual bool Close();
    42   bool GetPosition(UInt64 &position) const;
    43   bool GetLength(UInt64 &length) const;
    45   bool Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const;
    46   bool Seek(UInt64 position, UInt64 &newPosition); 
    47   bool SeekToBegin(); 
    48   bool SeekToEnd(UInt64 &newPosition); 
    50   bool GetFileInformation(CByHandleFileInfo &fileInfo) const;
    51 };
    53 class CInFile: public CFileBase
    54 {
    55 public:
    56   bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
    57   bool Open(LPCTSTR fileName);
    58   #ifndef _UNICODE
    59   bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
    60   bool Open(LPCWSTR fileName);
    61   #endif
    62   bool ReadPart(void *data, UInt32 size, UInt32 &processedSize);
    63   bool Read(void *data, UInt32 size, UInt32 &processedSize);
    64 };
    66 class COutFile: public CFileBase
    67 {
    68   // DWORD m_CreationDisposition;
    69 public:
    70   // COutFile(): m_CreationDisposition(CREATE_NEW){};
    71   bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
    72   bool Open(LPCTSTR fileName, DWORD creationDisposition);
    73   bool Create(LPCTSTR fileName, bool createAlways);
    75   #ifndef _UNICODE
    76   bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
    77   bool Open(LPCWSTR fileName, DWORD creationDisposition);
    78   bool Create(LPCWSTR fileName, bool createAlways);
    79   #endif
    81   /*
    82   void SetOpenCreationDisposition(DWORD creationDisposition)
    83     { m_CreationDisposition = creationDisposition; }
    84   void SetOpenCreationDispositionCreateAlways()
    85     { m_CreationDisposition = CREATE_ALWAYS; }
    86   */
    88   bool SetTime(const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime);
    89   bool SetLastWriteTime(const FILETIME *lastWriteTime);
    90   bool WritePart(const void *data, UInt32 size, UInt32 &processedSize);
    91   bool Write(const void *data, UInt32 size, UInt32 &processedSize);
    92   bool SetEndOfFile();
    93   bool SetLength(UInt64 length);
    94 };
    96 }}}
    98 #endif

mercurial