3 * Copyright (C) 2005-2010 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, write to
18 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19 * http://www.gnu.org/copyleft/gpl.html
26 #include "../FileSystem/File.h"
28 class CFileOperationJob
: public CJob
36 ActionReplace
, ///< Copy, emptying any existing destination directories first
41 CFileOperationJob(FileAction action
, CFileItemList
& items
, const CStdString
& strDestFile
);
43 virtual bool DoWork();
44 const CStdString
&GetAverageSpeed() { return m_avgSpeed
; }
45 const CStdString
&GetCurrentOperation() { return m_currentOperation
; }
46 const CStdString
&GetCurrentFile() { return m_currentFile
; }
47 const CFileItemList
&GetItems() { return m_items
; }
48 FileAction
GetAction() { return m_action
; }
50 class CFileOperation
: public XFILE::IFileCallback
53 CFileOperation(FileAction action
, const CStdString
&strFileA
, const CStdString
&strFileB
, int64_t time
);
54 bool ExecuteOperation(CFileOperationJob
*base
, double ¤t
, double opWeight
);
56 virtual bool OnFileCallback(void* pContext
, int ipercent
, float avgSpeed
);
59 CStdString m_strFileA
, m_strFileB
;
62 friend class CFileOperation
;
63 typedef std::vector
<CFileOperation
> FileOperationList
;
64 bool DoProcess(FileAction action
, CFileItemList
& items
, const CStdString
& strDestFile
, FileOperationList
&fileOperations
, double &totalTime
);
65 bool DoProcessFolder(FileAction action
, const CStdString
& strPath
, const CStdString
& strDestFile
, FileOperationList
&fileOperations
, double &totalTime
);
66 bool DoProcessFile(FileAction action
, const CStdString
& strFileA
, const CStdString
& strFileB
, FileOperationList
&fileOperations
, double &totalTime
);
68 static inline bool CanBeRenamed(const CStdString
&strFileA
, const CStdString
&strFileB
);
71 CFileItemList m_items
;
72 CStdString m_strDestFile
;
73 CStdString m_avgSpeed
, m_currentOperation
, m_currentFile
;