vfs: check userland buffers before reading them.
[haiku.git] / src / apps / haikudepot / server / BulkLoadContext.cpp
blobffa24302d7a3fb9351223631a65f9918b3e2936c
1 /*
2 * Copyright 2017, Andrew Lindesay <apl@lindesay.co.nz>.
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
5 #include "BulkLoadContext.h"
8 BulkLoadContext::BulkLoadContext()
10 fState(BULK_LOAD_INITIAL),
11 fIconProcess(NULL),
12 fRepositoryProcess(NULL),
13 fPkgProcesses(new List<AbstractServerProcess*, true>()),
14 fProcessOptions(0)
19 BulkLoadContext::~BulkLoadContext()
21 StopAllProcesses();
23 if (fIconProcess != NULL)
24 delete fIconProcess;
26 if (fRepositoryProcess != NULL)
27 delete fRepositoryProcess;
29 int32 count = fPkgProcesses->CountItems();
30 int32 i;
32 for (i = 0; i < count; i++)
33 delete fPkgProcesses->ItemAt(i);
35 delete fPkgProcesses;
39 bulk_load_state
40 BulkLoadContext::State()
42 return fState;
46 void
47 BulkLoadContext::SetState(bulk_load_state value)
49 fState = value;
53 void
54 BulkLoadContext::StopAllProcesses()
56 if (fIconProcess != NULL)
57 fIconProcess->Stop();
59 if (fRepositoryProcess != NULL)
60 fRepositoryProcess->Stop();
62 int32 count = fPkgProcesses->CountItems();
63 int32 i;
65 for (i = 0; i < count; i++)
66 fPkgProcesses->ItemAt(i)->Stop();
70 AbstractServerProcess*
71 BulkLoadContext::IconProcess()
73 return fIconProcess;
77 void
78 BulkLoadContext::SetIconProcess(AbstractServerProcess* value)
80 fIconProcess = value;
84 AbstractServerProcess*
85 BulkLoadContext::RepositoryProcess()
87 return fRepositoryProcess;
91 void
92 BulkLoadContext::SetRepositoryProcess(
93 AbstractServerProcess* value)
95 fRepositoryProcess = value;
99 int32
100 BulkLoadContext::CountPkgProcesses()
102 return fPkgProcesses->CountItems();
106 AbstractServerProcess*
107 BulkLoadContext::PkgProcessAt(int32 index)
109 return fPkgProcesses->ItemAt(index);
113 void
114 BulkLoadContext::AddPkgProcess(AbstractServerProcess *value)
116 fPkgProcesses->Add(value);
120 void
121 BulkLoadContext::AddProcessOption(uint32 flag)
123 fProcessOptions = fProcessOptions | flag;
127 uint32
128 BulkLoadContext::ProcessOptions()
130 return fProcessOptions;