FileManageLib.cpp
资源名称:FTP总集.rar [点击查看]
上传用户:tjfeida
上传日期:2013-03-10
资源大小:1917k
文件大小:6k
源码类别:
Ftp客户端
开发平台:
Visual C++
- // FileManageLib.cpp: implementation of the CFileManageLib class.
- //
- //////////////////////////////////////////////////////////////////////
- /*********************************************
- **该文件是属于WolfFTP工程中的。如果有什么问题
- **请联系
- ** tablejiang@21cn.com
- **或者访问
- ** http://wolfftp.51.net
- **以得到最新的支持。
- *********************************************/
- #include "stdafx.h"
- #include "QuickFTP.h"
- #include "FileManageLib.h"
- #include "shellapi.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CFileManageLib::CFileManageLib()
- {
- //init the data
- m_strFrom = NULL ;
- m_strTo = NULL ;
- m_dwFromBfSize = 0 ;
- m_dwFromUseSize = 0 ;
- m_dwToBfSize = 0 ;
- m_dwToUseSize = 0 ;
- }
- CFileManageLib::~CFileManageLib()
- {
- }
- /****************************************************
- ** @Description
- ** performs the delete file operation
- **
- ** @Parameter
- ** void
- **
- ** @Return: success return true ,else false .
- ** @Author :Table.JHM.太子
- ** e-mail :tablejiang@21cn.com
- ** Date :2001 3 26
- ****************************************************/
- BOOL CFileManageLib::DeleteFile( )
- {
- SHFILEOPSTRUCT st;
- st.hwnd = NULL;
- st.wFunc = FO_DELETE ;
- st.pFrom = m_strFrom ;
- st.pTo = NULL ;
- st.fFlags = 0;
- st.fAnyOperationsAborted = FALSE;
- st.hNameMappings = NULL;
- st.lpszProgressTitle = NULL;
- return ( !ActionRun(&st) ) ;
- }
- /****************************************************
- ** @Description
- ** performs the copy files operation
- **
- ** @Parameter
- ** void
- **
- ** @Return:
- ** @Author :Table.JHM.太子
- ** e-mail :tablejiang@21cn.com
- ** Date :2001 3 26
- ****************************************************/
- BOOL CFileManageLib::CopyFile( )
- {
- SHFILEOPSTRUCT st;
- st.hwnd = NULL;
- st.wFunc = FO_COPY ;
- st.pFrom = m_strFrom ;
- st.pTo = m_strTo ;
- st.fFlags = 0;
- st.fAnyOperationsAborted = FALSE;
- st.hNameMappings = NULL;
- st.lpszProgressTitle = NULL;
- return ( !ActionRun(&st) ) ;
- }
- /****************************************************
- ** @Description
- ** performs the move files operation
- **
- ** @Parameter
- **
- **
- ** @Return:
- ** @Author :Table.JHM.太子
- ** e-mail :tablejiang@21cn.com
- ** Date :2001 3 26
- ****************************************************/
- BOOL CFileManageLib::MoveFile( )
- {
- SHFILEOPSTRUCT st;
- st.hwnd = NULL;
- st.wFunc = FO_MOVE ;
- st.pFrom = m_strFrom ;
- st.pTo = m_strTo ;
- st.fFlags = 0;
- st.fAnyOperationsAborted = FALSE;
- st.hNameMappings = NULL;
- st.lpszProgressTitle = NULL;
- return ( !ActionRun(&st) ) ;
- }
- /****************************************************
- ** @Description
- ** performs the rename file operation
- **
- ** @Parameter
- **
- **
- ** @Return:
- ** @Author :Table.JHM.太子
- ** e-mail :tablejiang@21cn.com
- ** Date :2001 3 26
- ****************************************************/
- BOOL CFileManageLib::RenameFile( )
- {
- SHFILEOPSTRUCT st;
- st.hwnd = NULL;
- st.wFunc = FO_RENAME ;
- st.pFrom = m_strFrom ;
- st.pTo = m_strTo ;
- st.fFlags = 0;
- st.fAnyOperationsAborted = FALSE;
- st.hNameMappings = NULL;
- st.lpszProgressTitle = NULL;
- return ( !ActionRun(&st) ) ;
- }
- /****************************************************
- ** @Description
- ** add the source file path to file list .
- **
- ** @Parameter
- ** LPCTSTR szPathName : want add path .
- **
- ** @Return:
- ** @Author :Table.JHM.太子
- ** e-mail :tablejiang@21cn.com
- ** Date :2001 3 26
- ****************************************************/
- BOOL CFileManageLib::AddFromFileList( LPCTSTR szPathName )
- {
- char * pfrom ;
- if( m_dwFromBfSize <= m_dwFromUseSize )
- {
- //if the buffer small the request ,
- //then increase the buffer !.
- m_dwFromBfSize += CREATESIZE ;
- pfrom = (char*)realloc( (void*)m_strFrom , m_dwFromBfSize ) ;
- if( pfrom == NULL )
- return false ;
- m_strFrom = pfrom ;
- }
- //add to file list.
- char * szPos ;
- DWORD iLength = strlen( szPathName ) ;
- szPos = m_strFrom + m_dwFromUseSize ;
- memcpy( szPos , szPathName , iLength) ;
- szPos[iLength] = 0 ;
- m_dwFromUseSize += iLength ;
- m_dwFromUseSize ++ ;
- return true ;
- }
- /****************************************************
- ** @Description
- ** add the destination path to file list .
- **
- ** @Parameter
- **
- **
- ** @Return:
- ** @Author :Table.JHM.太子
- ** e-mail :tablejiang@21cn.com
- ** Date :2001 3 26
- ****************************************************/
- BOOL CFileManageLib::AddToFileList(LPCTSTR szPathName)
- {
- char * pto ;
- if( m_dwToBfSize <= m_dwToUseSize )
- {
- //if the buffer small the request ,
- //then increase the buffer !.
- m_dwToBfSize += CREATESIZE ;
- pto = (char*)realloc( m_strTo , m_dwToBfSize ) ;
- if( pto == NULL )
- return false ;
- m_strTo = pto ;
- }
- char * szPos ;
- DWORD iLength = strlen( szPathName ) ;
- szPos = m_strTo + m_dwToUseSize ;
- memcpy( szPos , szPathName , iLength) ;
- szPos[iLength] = 0 ;
- m_dwToUseSize += iLength ;
- m_dwToUseSize ++ ;
- return true ;
- }
- /****************************************************
- ** @Description
- ** this function is run the operation
- **
- ** @Parameter
- **
- **
- ** @Return:
- ** @Author :Table.JHM.太子
- ** e-mail :tablejiang@21cn.com
- ** Date :2001 3 26
- ****************************************************/
- BOOL CFileManageLib::ActionRun(SHFILEOPSTRUCT *pSt)
- {
- BOOL bRet ;
- //add the