4 * Copyright (C) 2005-2013 Team XBMC
7 * This Program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This Program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with XBMC; see the file COPYING. If not, see
19 * <http://www.gnu.org/licenses/>.
23 #include "threads/Thread.h"
24 #include "filesystem/File.h"
26 class CAsyncFileCopy : public CThread, public XFILE::IFileCallback
30 virtual ~CAsyncFileCopy();
32 /// \brief Main routine to copy files from one source to another.
33 /// \return true if successful, and false if it failed or was cancelled.
34 bool Copy(const CStdString &from, const CStdString &to, const CStdString &heading);
36 /// \brief callback from CFile::Cache()
37 virtual bool OnFileCallback(void *pContext, int ipercent, float avgSpeed);
40 virtual void Process();
43 /// volatile variables as we access these from both threads
44 volatile int m_percent; ///< current percentage (0..100)
45 volatile float m_speed; ///< current speed (in bytes per second)
46 volatile bool m_cancelled; ///< whether or not we cancelled the operation
47 volatile bool m_running; ///< whether or not the copy operation is still in progress
49 bool m_succeeded; ///< whether or not the copy operation was successful
50 CStdString m_from; ///< source URL to copy from
51 CStdString m_to; ///< destination URL to copy to
52 CEvent m_event; ///< event to set to force an update