Copy Files Project

C++ Source Files in the Project:

cpfiles.cpp | copyfiles_utilities.cpp | filecopy.cpp

C++ Header Files in the Project:

cpfiles.h | copyfiles_utilities.h | filecopy.h

 

 
// =================================================================
// File Name:	cpfiles_utilities.h
// Created by:	Xuan Sun
// Date:		Jan 2000
// =================================================================				

#ifndef _COPYFILES_UTILITIES_H
#define _COPYFILES_UTILITIES_H

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// utilities.h : header file

// more efficient than CStdioFile class
class CASCIIFile : public CObject
{
// Construction
public:
	CASCIIFile(LPCTSTR filename, UINT nOpenFlags);
	virtual ~CASCIIFile();

	BOOL	ReadLine(CString &str);
	void	WriteLine(LPCTSTR lpstr, INT nsize);
	void	WriteLine(const CString &str);
	BOOL	ReadChar(LPINT lptbyte);
	BOOL	UnReadChar();
	DWORD	ReadToEnd(CString &str);
	void	SeekToBegin();

private:
	DWORD	m_dwFilesize;
	DWORD	m_dwPosition;
	CFile  *m_pCFile;

	UINT	Read(void* lpBuf, UINT nCount);
	void	Write(const void* lpBuf, UINT nCount);
	LONG	Seek(LONG lOff, UINT nFrom);
};

class CINIFile : public CASCIIFile
{
// Construction
public:
	CINIFile(LPCTSTR lpiniFileName, UINT nOpenFlags = CFile::modeRead);
	virtual ~CINIFile();

public:
	int		ReadSection(CStringArray &keys, CStringArray &values, LPCTSTR lpSection);
	int		ReadSection(CMapStringToString &map, LPCTSTR lpSection);
	
	INT		CountEnumSections(LPCTSTR lpstrPattern, int nFirstIndex = 1);

	// return size of string
	INT		ReadString(LPCTSTR lpSection, LPCTSTR lpKey, CString& str, LPCTSTR lpDefault = "");
	BOOL	WriteString(LPCTSTR lpSection, LPCTSTR lpKey, LPCTSTR lpstr);
	
	BOOL	WriteInt(LPCTSTR lpSection, LPCTSTR lpKey, INT nValue);
	INT		ReadInt(LPCTSTR lpSection, LPCTSTR lpKey, INT nDefault=0);

protected:
	BOOL	FindSection(LPCTSTR lpSection);
	BOOL	FindNextLine(CString &strKey, CString &strValue);

private:
	BOOL	m_bReadOnly;
};

BOOL is_file_existed(LPCTSTR lpfilename);
BOOL GetINIPathEntry( CString &strpath, LPCTSTR lpINIFile, LPCTSTR lpEntry);
BOOL GetPathFromFileName(LPCTSTR lpszFullPathName, CString &strPath, CString *lpstrPureFileName=NULL);
int GetFileList(LPCTSTR lpszFileSpecification, CStringArray &strList);
BOOL AddBackStroke ( CString &strAPurePath );

#endif// !_COPYFILES_UTILITIES_H