diff src/win32/7zip/7z/CPP/Windows/FileIO.h @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/win32/7zip/7z/CPP/Windows/FileIO.h	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,99 @@
     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 CTime;
    1.19 +  FILETIME ATime;
    1.20 +  FILETIME MTime;
    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 +  HANDLE _handle;
    1.31 +  bool Create(LPCTSTR fileName, DWORD desiredAccess,
    1.32 +      DWORD shareMode, DWORD creationDisposition,  DWORD flagsAndAttributes);
    1.33 +  #ifndef _UNICODE
    1.34 +  bool Create(LPCWSTR fileName, DWORD desiredAccess,
    1.35 +      DWORD shareMode, DWORD creationDisposition,  DWORD flagsAndAttributes);
    1.36 +  #endif
    1.37 +
    1.38 +public:
    1.39 +  CFileBase(): _handle(INVALID_HANDLE_VALUE){};
    1.40 +  ~CFileBase();
    1.41 +
    1.42 +  bool Close();
    1.43 +
    1.44 +  bool GetPosition(UInt64 &position) const;
    1.45 +  bool GetLength(UInt64 &length) const;
    1.46 +
    1.47 +  bool Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const;
    1.48 +  bool Seek(UInt64 position, UInt64 &newPosition);
    1.49 +  bool SeekToBegin();
    1.50 +  bool SeekToEnd(UInt64 &newPosition);
    1.51 +  
    1.52 +  bool GetFileInformation(CByHandleFileInfo &fileInfo) const;
    1.53 +};
    1.54 +
    1.55 +class CInFile: public CFileBase
    1.56 +{
    1.57 +public:
    1.58 +  bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
    1.59 +  bool OpenShared(LPCTSTR fileName, bool shareForWrite);
    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 OpenShared(LPCWSTR fileName, bool shareForWrite);
    1.64 +  bool Open(LPCWSTR fileName);
    1.65 +  #endif
    1.66 +  bool ReadPart(void *data, UInt32 size, UInt32 &processedSize);
    1.67 +  bool Read(void *data, UInt32 size, UInt32 &processedSize);
    1.68 +};
    1.69 +
    1.70 +class COutFile: public CFileBase
    1.71 +{
    1.72 +  // DWORD m_CreationDisposition;
    1.73 +public:
    1.74 +  // COutFile(): m_CreationDisposition(CREATE_NEW){};
    1.75 +  bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
    1.76 +  bool Open(LPCTSTR fileName, DWORD creationDisposition);
    1.77 +  bool Create(LPCTSTR fileName, bool createAlways);
    1.78 +
    1.79 +  #ifndef _UNICODE
    1.80 +  bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
    1.81 +  bool Open(LPCWSTR fileName, DWORD creationDisposition);
    1.82 +  bool Create(LPCWSTR fileName, bool createAlways);
    1.83 +  #endif
    1.84 +
    1.85 +  /*
    1.86 +  void SetOpenCreationDisposition(DWORD creationDisposition)
    1.87 +    { m_CreationDisposition = creationDisposition; }
    1.88 +  void SetOpenCreationDispositionCreateAlways()
    1.89 +    { m_CreationDisposition = CREATE_ALWAYS; }
    1.90 +  */
    1.91 +
    1.92 +  bool SetTime(const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime);
    1.93 +  bool SetMTime(const FILETIME *mTime);
    1.94 +  bool WritePart(const void *data, UInt32 size, UInt32 &processedSize);
    1.95 +  bool Write(const void *data, UInt32 size, UInt32 &processedSize);
    1.96 +  bool SetEndOfFile();
    1.97 +  bool SetLength(UInt64 length);
    1.98 +};
    1.99 +
   1.100 +}}}
   1.101 +
   1.102 +#endif