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

📄 filechangeevent.h

📁 本程序使您在文件改变时得到通知
💻 H
字号:
// FileChangeEvent.h: interface for the CFileChangeEvent class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_FILECHANGEEVENT_H__1B890621_FEC8_11D2_B9E0_704B7C000000__INCLUDED_)
#define AFX_FILECHANGEEVENT_H__1B890621_FEC8_11D2_B9E0_704B7C000000__INCLUDED_

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

//
// Author   : Franky Braem
// Created  : 30/04/1999
// Modified : 17/05/1999 - Use the drive of the path instead of current drive
//			  18/05/1999 - Use the current path if no path specified

#pragma warning(disable:4786)

#include <string>
#include <map>
#include <vector>

#include <afxmt.h>

class CFileInfo;

class CFilePath
{
public:
	CFilePath(const std::string &sPath) { m_sName = sPath;m_nCount = 0; }
	inline std::string getName(void) const { return m_sName; }
	inline void operator++(int) { m_nCount++; }
	inline void operator--(int) { m_nCount--; }
	inline int getCount(void) { return m_nCount; }
protected :
	std::string m_sName;
	int m_nCount;
};

typedef std::map<std::string, CFileInfo *> FileInfoMap;
typedef std::vector<CFilePath *> FilePathVector;

class CFileChangeEvent  
{
public:
	enum FileAlarm { FA_CHANGED, FA_REMOVED, FA_CREATED };
	CFileChangeEvent();
	virtual ~CFileChangeEvent();
	void addFile(const std::string &sFileName);
	void removeFile(const std::string &sFileName);
	void startWatch(void);
	void stopWatch(void);
	inline bool isWatching(void) const { return m_bEvent; }
protected:
	virtual void OnFileAlarm(FileAlarm nAlarm, const std::string &sFileName) {}	
	CEvent m_evStopWatch;
	FileInfoMap m_FileInfoMap;
	FilePathVector m_Paths;
	bool m_bEvent;
	static UINT FileChangeWatch(LPVOID lpParam);
};

#endif // !defined(AFX_FILECHANGEEVENT_H__1B890621_FEC8_11D2_B9E0_704B7C000000__INCLUDED_)

⌨️ 快捷键说明

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