changed: update version strings for beta4
[xbmc.git] / xbmc / utils / FileOperationJob.h
blobb331b8893af92c91674ff169c0fe63346e0f30f1
1 #pragma once
2 /*
3 * Copyright (C) 2005-2010 Team XBMC
4 * http://www.xbmc.org
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)
9 * any later version.
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
23 #include "system.h"
24 #include "FileItem.h"
25 #include "Job.h"
26 #include "../FileSystem/File.h"
28 class CFileOperationJob : public CJob
30 public:
31 enum FileAction
33 ActionCopy = 1,
34 ActionMove,
35 ActionDelete,
36 ActionReplace, ///< Copy, emptying any existing destination directories first
37 ActionCreateFolder,
38 ActionDeleteFolder,
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; }
49 private:
50 class CFileOperation : public XFILE::IFileCallback
52 public:
53 CFileOperation(FileAction action, const CStdString &strFileA, const CStdString &strFileB, int64_t time);
54 bool ExecuteOperation(CFileOperationJob *base, double &current, double opWeight);
55 void Debug();
56 virtual bool OnFileCallback(void* pContext, int ipercent, float avgSpeed);
57 private:
58 FileAction m_action;
59 CStdString m_strFileA, m_strFileB;
60 int64_t m_time;
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);
70 FileAction m_action;
71 CFileItemList m_items;
72 CStdString m_strDestFile;
73 CStdString m_avgSpeed, m_currentOperation, m_currentFile;