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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/other-licenses/7zstub/src/Windows/FileIO.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,98 @@
     1.4 +// Windows/FileIO.h
     1.5 +
     1.6 +#ifndef __WINDOWS_FILEIO_H
     1.7 +#define __WINDOWS_FILEIO_H
     1.8 +
     1.9 +#include "../Common/Types.h"
    1.10 +
    1.11 +namespace NWindows {
    1.12 +namespace NFile {
    1.13 +namespace NIO {
    1.14 +
    1.15 +struct CByHandleFileInfo
    1.16 +{ 
    1.17 +  DWORD    Attributes; 
    1.18 +  FILETIME CreationTime; 
    1.19 +  FILETIME LastAccessTime; 
    1.20 +  FILETIME LastWriteTime; 
    1.21 +  DWORD    VolumeSerialNumber; 
    1.22 +  UInt64   Size;
    1.23 +  DWORD    NumberOfLinks; 
    1.24 +  UInt64   FileIndex; 
    1.25 +};
    1.26 +
    1.27 +class CFileBase
    1.28 +{
    1.29 +protected:
    1.30 +  bool _fileIsOpen;
    1.31 +  HANDLE _handle;
    1.32 +  bool Create(LPCTSTR fileName, DWORD desiredAccess,
    1.33 +      DWORD shareMode, DWORD creationDisposition,  DWORD flagsAndAttributes);
    1.34 +  #ifndef _UNICODE
    1.35 +  bool Create(LPCWSTR fileName, DWORD desiredAccess,
    1.36 +      DWORD shareMode, DWORD creationDisposition,  DWORD flagsAndAttributes);
    1.37 +  #endif
    1.38 +
    1.39 +public:
    1.40 +  CFileBase(): _fileIsOpen(false){};
    1.41 +  virtual ~CFileBase();
    1.42 +
    1.43 +  virtual bool Close();
    1.44 +
    1.45 +  bool GetPosition(UInt64 &position) const;
    1.46 +  bool GetLength(UInt64 &length) const;
    1.47 +
    1.48 +  bool Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const;
    1.49 +  bool Seek(UInt64 position, UInt64 &newPosition); 
    1.50 +  bool SeekToBegin(); 
    1.51 +  bool SeekToEnd(UInt64 &newPosition); 
    1.52 +  
    1.53 +  bool GetFileInformation(CByHandleFileInfo &fileInfo) const;
    1.54 +};
    1.55 +
    1.56 +class CInFile: public CFileBase
    1.57 +{
    1.58 +public:
    1.59 +  bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
    1.60 +  bool Open(LPCTSTR fileName);
    1.61 +  #ifndef _UNICODE
    1.62 +  bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
    1.63 +  bool Open(LPCWSTR fileName);
    1.64 +  #endif
    1.65 +  bool ReadPart(void *data, UInt32 size, UInt32 &processedSize);
    1.66 +  bool Read(void *data, UInt32 size, UInt32 &processedSize);
    1.67 +};
    1.68 +
    1.69 +class COutFile: public CFileBase
    1.70 +{
    1.71 +  // DWORD m_CreationDisposition;
    1.72 +public:
    1.73 +  // COutFile(): m_CreationDisposition(CREATE_NEW){};
    1.74 +  bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
    1.75 +  bool Open(LPCTSTR fileName, DWORD creationDisposition);
    1.76 +  bool Create(LPCTSTR fileName, bool createAlways);
    1.77 +
    1.78 +  #ifndef _UNICODE
    1.79 +  bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
    1.80 +  bool Open(LPCWSTR fileName, DWORD creationDisposition);
    1.81 +  bool Create(LPCWSTR fileName, bool createAlways);
    1.82 +  #endif
    1.83 +
    1.84 +  /*
    1.85 +  void SetOpenCreationDisposition(DWORD creationDisposition)
    1.86 +    { m_CreationDisposition = creationDisposition; }
    1.87 +  void SetOpenCreationDispositionCreateAlways()
    1.88 +    { m_CreationDisposition = CREATE_ALWAYS; }
    1.89 +  */
    1.90 +
    1.91 +  bool SetTime(const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime);
    1.92 +  bool SetLastWriteTime(const FILETIME *lastWriteTime);
    1.93 +  bool WritePart(const void *data, UInt32 size, UInt32 &processedSize);
    1.94 +  bool Write(const void *data, UInt32 size, UInt32 &processedSize);
    1.95 +  bool SetEndOfFile();
    1.96 +  bool SetLength(UInt64 length);
    1.97 +};
    1.98 +
    1.99 +}}}
   1.100 +
   1.101 +#endif

mercurial