Click here to Skip to main content
13,051,404 members (65,237 online)
Click here to Skip to main content


98 bookmarked
Posted 23 Nov 1999

CFileInfoArray: A class for gathering file information recursively through directories

, 23 Nov 1999
This class gathers file information recursively by directory and, as a bonus track, it also calculates the 32bit file-checksum and CRC
 * @doc FCOMPARE
 * @module FCompareDlg.h - Interface for the FCompare dialog class application |
 * This application is a sample of CFileInfo and CFileInfoArray usage
 * <cp> Codeguru & friends
 * Coded by Antonio Tejada Lacaci. 1999<nl>
 * Updates:<nl>
 *  1999-4-30 ATL: Corrected a bug when setting timers: requested timer was id 0 and MSDN help states
 *                 that the timer id must be greater than 0. This bug was pointed out to me by 
 *                 Javier Maura (´┐Żalthough the timer _does_ work even if its id is 0!!!).
 *                 The user is also warned about progress not being reported if SetTimer fails.
 * Keep this comment if you redistribute this file. And credit where credit's due!

#if !defined(AFX_FCOMPAREDLG_H__00F8A567_CFF8_11D2_AA42_A54123628E22__INCLUDED_)
#define AFX_FCOMPAREDLG_H__00F8A567_CFF8_11D2_AA42_A54123628E22__INCLUDED_

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

#include "FileInfo.h"


// CFCompareDlg dialog

typedef struct {
   CFileInfo* pfinSource;
   CFileInfo* pfinTarget;

class CFCompareDlg : public CDialog {
// Construction
	CFCompareDlg(CWnd* pParent = NULL);	// standard constructor

   void UpdateCounters();
   BOOL CompareContents(CFileInfo* pfinSrc, CFileInfo* pfinDest, const DWORD dwUpTo, 
      volatile BOOL bAbort);
// Dialog Data
	// Dialog Data
	enum { IDD = DLG_FCOMPARE };
	CStatic	m_lblStatus;
	CStatic	m_lblTargetFiles;
	CStatic	m_lblSourceFiles;
	CStatic	m_lblMatchedFiles;
	CListCtrl	m_lstMatchedFiles;
	CTabCtrl	m_tabAction;
	CListCtrl	m_lstTargetFiles;
	CListCtrl	m_lstSourceFiles;
	CProgressCtrl	m_prgProgress;
	BOOL	m_bRecurse;
	int		m_nMatchCriteria;
	DWORD	m_dwUpto;
	CString	m_strAllowedMasks;
	CString	m_strDirectory;
	BOOL	m_bCompareDuplicates;

   CFileInfoArray m_fiaTargetInfos;
   CFileInfoArray m_fiaSourceInfos;
   CFileInfoArray* m_pfiaInfos; // Array where search thread will add FileInfos
   CListCtrl* m_plstFiles;      // ListView where search thread will add files
   CArray<MATCHSTRUCT, MATCHSTRUCT&> m_msaMatchedInfos;

   // Flags for thread communication
   volatile BOOL m_bAbort;
   volatile BOOL m_bExit;
   volatile BOOL m_bAddInProgress;
   volatile BOOL m_bCompareInProgress;
   volatile BOOL m_bFillInProgress;
   volatile ULONG m_ulProgress;
   volatile ULONG m_ulProgressMax;

	// ClassWizard generated virtual function overrides
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support

// Implementation
	HICON m_hIcon;

   // Busy state
   // Property pages

   int m_bsState;  // Busy state 
   void SetBusyState(int bsState);

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnMatchContents();
	afx_msg void OnMatchCriteria();
	afx_msg void OnCompare();
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnGetdispinfoSearchFiles(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnExit();
	afx_msg void OnSelchangeAction(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnGetdispinfoMatchedFiles(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnExploreDirectory();
	afx_msg void OnAddSourceFiles();
	afx_msg void OnAddTargetFiles();
	afx_msg void OnClearSourceFiles();
	afx_msg void OnClearTargetFiles();
	afx_msg void OnClose();
	afx_msg void OnExport();
   afx_msg LONG OnSearchFinished(WPARAM wparam, LPARAM lparam);
   afx_msg LONG OnCompareFinished(WPARAM wparam, LPARAM lparam);

// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_FCOMPAREDLG_H__00F8A567_CFF8_11D2_AA42_A54123628E22__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 24 Nov 1999
Article Copyright 1999 by Antonio Tejada Lacaci
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid