⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 file.h

📁 手机数据备份软件
💻 H
字号:
// File1.h: interface for the CFile class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_FILE1_H__CA5FFBBF_3A63_46E5_84D8_303054A258C2__INCLUDED_)
#define AFX_FILE1_H__CA5FFBBF_3A63_46E5_84D8_303054A258C2__INCLUDED_

#include "Time.h"

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#ifndef ASSERT
#define ASSERT ATLASSERT
#endif

struct CFileStatus
{
    CTime m_ctime;          // creation date/time of file
    CTime m_mtime;          // last modification date/time of file
    CTime m_atime;          // last access date/time of file
    LONG m_size;            // logical size of file in bytes
    BYTE m_attribute;       // logical OR of CFile::Attribute enum values
    BYTE _m_padding;        // pad the structure to a WORD
    TCHAR m_szFullName[_MAX_PATH]; // absolute path name
};
class CFileException
{
public:
// Constructor
    CFileException(int cause = 0) { m_cause = cause; };
    virtual ~CFileException(){};
	int ReportError()
	{
		return m_cause;
/*
		CString str;
		str.Format(_T("Errorno = %d,File:%s"),m_cause,_THIS_FILE_);
		MessageBox(NULL,str,NULL,MB_ICONSTOP|MB_OK);
*/	
	}
// Attributes
    int     m_cause;
};

class CFile
{
public:
// Flag values
    enum OpenFlags {
        modeRead =          0x0000,
        modeWrite =         0x0001,
        modeReadWrite =     0x0002,
        shareCompat =       0x0000,
        shareExclusive =    0x0010,
        shareDenyWrite =    0x0020,
        shareDenyRead =     0x0030,
        shareDenyNone =     0x0040,
        modeNoInherit =     0x0080,
        modeCreate =        0x1000,
        modeNoTruncate =    0x2000,
        typeText =          0x4000, 
        typeBinary =   (int)0x8000 
        };

    enum Attribute {
        normal =    0x00,
        readOnly =  0x01,
        hidden =    0x02,
        system =    0x04,
        volume =    0x08,
        directory = 0x10,
        archive =   0x20
        };

    enum SeekPosition { begin = 0x0, current = 0x1, end = 0x2 };

    enum { hFileNull = -1 };

// Constructors
    CFile();
    CFile(int hFile);
    CFile(LPCTSTR lpszFileName, UINT nOpenFlags);

// Attributes
    UINT m_hFile;
    operator HFILE() const 	{ return m_hFile; };

    virtual DWORD GetPosition() const;
//    BOOL GetStatus(CFileStatus& rStatus) const;
//    virtual CString GetFileName() const;
//    virtual CString GetFileTitle() const;
//    virtual CString GetFilePath() const;
//    virtual void SetFilePath(LPCTSTR lpszNewName);

// Operations
    virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags,
        CFileException* pError = NULL);

    static void PASCAL Rename(LPCTSTR lpszOldName,
                LPCTSTR lpszNewName);
    static void PASCAL Remove(LPCTSTR lpszFileName);
//    static BOOL PASCAL GetStatus(LPCTSTR lpszFileName,
//                CFileStatus& rStatus);
//    static void PASCAL SetStatus(LPCTSTR lpszFileName,
//                const CFileStatus& status);

    DWORD SeekToEnd();
    void SeekToBegin();

    // backward compatible ReadHuge and WriteHuge
    DWORD ReadHuge(void* lpBuffer, DWORD dwCount);
    void WriteHuge(const void* lpBuffer, DWORD dwCount);

// Overridables

    virtual LONG Seek(LONG lOff, UINT nFrom);
    virtual void SetLength(DWORD dwNewLen);
    virtual DWORD GetLength() const;

    virtual UINT Read(void* lpBuf, UINT nCount);
    virtual UINT Write(const void* lpBuf, UINT nCount);

    virtual void Abort();
    virtual void Flush();
    virtual void Close();

// Implementation
public:
    virtual ~CFile();
    enum BufferCommand { bufferRead, bufferWrite, bufferCommit, bufferCheck };
protected:
    BOOL m_bCloseOnDelete;
    CString m_strFileName;
};

#endif // !defined(AFX_FILE1_H__CA5FFBBF_3A63_46E5_84D8_303054A258C2__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -