1/*
2 * Copyright 2016, Rene Gollent, rene@gollent.com.
3 * Distributed under the terms of the MIT License.
4 */
5
6#include "Jobs.h"
7
8#include <Path.h>
9
10#include <AutoLocker.h>
11
12#include "DebuggerInterface.h"
13#include "Team.h"
14
15
16
17WriteCoreFileJob::WriteCoreFileJob(Team* team,
18	DebuggerInterface* interface, const entry_ref& path)
19	:
20	fKey(&path, JOB_TYPE_WRITE_CORE_FILE),
21	fTeam(team),
22	fDebuggerInterface(interface),
23	fTargetPath(path)
24{
25	fDebuggerInterface->AcquireReference();
26}
27
28
29WriteCoreFileJob::~WriteCoreFileJob()
30{
31	fDebuggerInterface->AcquireReference();
32}
33
34
35const JobKey&
36WriteCoreFileJob::Key() const
37{
38	return fKey;
39}
40
41
42status_t
43WriteCoreFileJob::Do()
44{
45	BPath path(&fTargetPath);
46	status_t error = path.InitCheck();
47	if (error != B_OK)
48		return error;
49
50	error = fDebuggerInterface->WriteCoreFile(path.Path());
51	if (error != B_OK)
52		return error;
53
54	AutoLocker< ::Team> teamLocker(fTeam);
55	fTeam->NotifyCoreFileChanged(path.Path());
56
57	return B_OK;
58}
59