- If it was necessary to help the debugger locate a particular source file due to it not being found on disk at the location specified in the debug information, the associated user-supplied path mappings are now saved and restored in the team settings. The file manager still needs a bit of extra work to apply these as files are added though.
129 lines
2.1 KiB
C++
129 lines
2.1 KiB
C++
/*
|
|
* Copyright 2013, Rene Gollent, [email protected].
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#include "TeamFileManagerSettings.h"
|
|
|
|
TeamFileManagerSettings::TeamFileManagerSettings()
|
|
:
|
|
fValues()
|
|
{
|
|
}
|
|
|
|
|
|
TeamFileManagerSettings::~TeamFileManagerSettings()
|
|
{
|
|
}
|
|
|
|
|
|
TeamFileManagerSettings&
|
|
TeamFileManagerSettings::operator=(const TeamFileManagerSettings& other)
|
|
{
|
|
fValues = other.fValues;
|
|
|
|
return *this;
|
|
}
|
|
|
|
|
|
const char*
|
|
TeamFileManagerSettings::ID() const
|
|
{
|
|
return "FileManager";
|
|
}
|
|
|
|
|
|
status_t
|
|
TeamFileManagerSettings::SetTo(const BMessage& archive)
|
|
{
|
|
try {
|
|
fValues = archive;
|
|
} catch (...) {
|
|
return B_NO_MEMORY;
|
|
}
|
|
|
|
return B_OK;
|
|
}
|
|
|
|
|
|
status_t
|
|
TeamFileManagerSettings::WriteTo(BMessage& archive) const
|
|
{
|
|
try {
|
|
archive = fValues;
|
|
} catch (...) {
|
|
return B_NO_MEMORY;
|
|
}
|
|
|
|
return B_OK;
|
|
}
|
|
|
|
|
|
int32
|
|
TeamFileManagerSettings::CountSourceMappings() const
|
|
{
|
|
type_code type;
|
|
int32 count = 0;
|
|
|
|
if (fValues.GetInfo("source:mapping", &type, &count) == B_OK)
|
|
return count;
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
status_t
|
|
TeamFileManagerSettings::AddSourceMapping(const BString& sourcePath,
|
|
const BString& locatedPath)
|
|
{
|
|
BMessage mapping;
|
|
if (mapping.AddString("source:path", sourcePath) != B_OK
|
|
|| mapping.AddString("source:locatedpath", locatedPath) != B_OK
|
|
|| fValues.AddMessage("source:mapping", &mapping) != B_OK) {
|
|
return B_NO_MEMORY;
|
|
}
|
|
|
|
return B_OK;
|
|
}
|
|
|
|
|
|
status_t
|
|
TeamFileManagerSettings::RemoveSourceMappingAt(int32 index)
|
|
{
|
|
return fValues.RemoveData("mapping", index);
|
|
}
|
|
|
|
|
|
status_t
|
|
TeamFileManagerSettings::GetSourceMappingAt(int32 index, BString& sourcePath,
|
|
BString& locatedPath)
|
|
{
|
|
BMessage mapping;
|
|
status_t error = fValues.FindMessage("mapping", index, &mapping);
|
|
if (error != B_OK)
|
|
return error;
|
|
|
|
error = mapping.FindString("source:path", &sourcePath);
|
|
if (error != B_OK)
|
|
return error;
|
|
|
|
return mapping.FindString("source:locatedpath", &locatedPath);
|
|
}
|
|
|
|
|
|
TeamFileManagerSettings*
|
|
TeamFileManagerSettings::Clone() const
|
|
{
|
|
TeamFileManagerSettings* settings = new(std::nothrow)
|
|
TeamFileManagerSettings();
|
|
|
|
if (settings == NULL)
|
|
return NULL;
|
|
|
|
if (settings->SetTo(fValues) != B_OK) {
|
|
delete settings;
|
|
return NULL;
|
|
}
|
|
|
|
return settings;
|
|
}
|