2 * Copyright 2008-2009, Stephan Aßmus <superstippi@gmx.de>
3 * All rights reserved. Distributed under the terms of the MIT License.
13 #include <Messenger.h>
16 #include "BlockingQueue.h"
19 class ProgressReporter
;
27 CopyEngine(ProgressReporter
* reporter
,
28 EntryFilter
* entryFilter
);
29 virtual ~CopyEngine();
31 void ResetTargets(const char* source
);
32 status_t
CollectTargets(const char* source
,
33 sem_id cancelSemaphore
= -1);
35 status_t
CopyFolder(const char* source
,
36 const char* destination
,
37 sem_id cancelSemaphore
= -1);
39 status_t
CopyFile(const BEntry
& entry
,
40 const BEntry
& destination
,
41 sem_id cancelSemaphore
= -1);
44 status_t
_CollectCopyInfo(const char* source
,
45 int32
& level
, sem_id cancelSemaphore
);
46 status_t
_CopyFolder(const char* source
,
47 const char* destination
,
48 int32
& level
, sem_id cancelSemaphore
);
50 status_t
_RemoveFolder(BEntry
& entry
);
52 const char* _RelativeEntryPath(
53 const char* absoluteSourcePath
) const;
55 void _UpdateProgress();
57 static int32
_WriteThreadEntry(void* cookie
);
63 BUFFER_SIZE
= 1024 * 1024
69 buffer(malloc(BUFFER_SIZE
)),
89 BlockingQueue
<Buffer
> fBufferQueue
;
91 thread_id fWriterThread
;
92 volatile bool fQuitting
;
94 BString fAbsoluteSourcePath
;
99 uint64 fLastItemsCopied
;
103 bigtime_t fTimeWritten
;
108 const char* fCurrentTargetFolder
;
109 const char* fCurrentItem
;
111 ProgressReporter
* fProgressReporter
;
112 EntryFilter
* fEntryFilter
;
116 class CopyEngine::EntryFilter
{
118 virtual ~EntryFilter();
120 virtual bool ShouldCopyEntry(const BEntry
& entry
,
122 const struct stat
& statInfo
,
123 int32 level
) const = 0;
124 virtual bool ShouldClobberFolder(const BEntry
& entry
,
126 const struct stat
& statInfo
,
127 int32 level
) const = 0;
131 #endif // COPY_ENGINE_H