You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.2 KiB
C++

//////////////////////////////////////////////////////////////////////////////
//文件 SplitPath.h
//主要功能:
//
//程序编写: 2005-12-07
/////////////////////////////////////////////////////////////////////////////
#ifndef __SPLITPATH_H
#define __SPLITPATH_H
/////////////////////////////////////////////////////////////////////////////
// CSplitPath class
class AFX_EXT_CLASS CSplitPath
{
// Construction / destruction
public:
// Constructs a CSplitPath object.
CSplitPath(LPCTSTR lpszPathBuffer=NULL);
// Destroys a CSplitPath object, handles cleanup and de-allocation.
virtual ~CSplitPath();
// Member variables
protected:
TCHAR m_szDrive[_MAX_DRIVE];
TCHAR m_szDir[_MAX_DIR];
TCHAR m_szFName[_MAX_FNAME];
TCHAR m_szExt[_MAX_EXT];
CString m_strSource;
// Member functions
public:
void SplitPath(LPCTSTR lpszPathBuffer);
CString GetDrive() const;
CString GetDir() const;
CString GetName() const;
CString GetExtension() const;
CString GetPath() const;
CString GetFullName() const;
CString GetPathName() const;
BOOL SetModuleFileName(void); //设置GetModuleFileName所获得的文件名称
BOOL SetTempPathFileName(LPCTSTR lpPrefixString = _T("NEW")); //设置临时目录临时文件名称
BOOL IsExist(void);
//将类似 ..\ 或 .\ 路径转换为绝对路径
CString GetAbsolutePath(LPCTSTR lpszPath); //获得绝对路径 针对当前模块所在路径而言
CString GetRelativePath(LPCTSTR lpszPath); //获得相对路径
BOOL MakeDirectory(CString dd); //创建多级目录
};
/////////////////////////////////////////////////////////////////////////////
AFX_INLINE CString CSplitPath::GetDrive() const {
return CString(m_szDrive);
}
AFX_INLINE CString CSplitPath::GetDir() const {
return CString(m_szDir);
}
AFX_INLINE CString CSplitPath::GetName() const {
return CString(m_szFName);
}
AFX_INLINE CString CSplitPath::GetExtension() const {
return CString(m_szExt);
}
AFX_INLINE CString CSplitPath::GetPath() const {
return GetDrive() + GetDir();
}
AFX_INLINE CString CSplitPath::GetFullName() const {
return GetName() + GetExtension();
}
AFX_INLINE CString CSplitPath::GetPathName() const {
return m_strSource;
}
/////////////////////////////////////////////////////////////////////////////
#endif // __SPLITPATH_H