Debugger: Implement #9961.
- FileManager now saves any explicitly located file mappings, and properly restores them when reloading the same team/files later.
This commit is contained in:
@@ -543,8 +543,7 @@ FileManager::FileManager()
|
|||||||
fLock("file manager"),
|
fLock("file manager"),
|
||||||
fTargetDomain(NULL),
|
fTargetDomain(NULL),
|
||||||
fSourceDomain(NULL),
|
fSourceDomain(NULL),
|
||||||
fSourceFiles(NULL),
|
fSourceFiles(NULL)
|
||||||
fLocationMappings()
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -613,7 +612,8 @@ FileManager::GetTargetFile(const BString& path)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FileManager::TargetEntryLocated(const BString& path, const BString& locatedPath)
|
FileManager::TargetEntryLocated(const BString& path,
|
||||||
|
const BString& locatedPath)
|
||||||
{
|
{
|
||||||
AutoLocker<FileManager> locker(this);
|
AutoLocker<FileManager> locker(this);
|
||||||
fTargetDomain->EntryLocated(path, locatedPath);
|
fTargetDomain->EntryLocated(path, locatedPath);
|
||||||
@@ -625,7 +625,14 @@ FileManager::GetSourceFile(const BString& directory,
|
|||||||
const BString& relativePath)
|
const BString& relativePath)
|
||||||
{
|
{
|
||||||
AutoLocker<FileManager> locker(this);
|
AutoLocker<FileManager> locker(this);
|
||||||
return fSourceDomain->GetFile(directory, relativePath);
|
LocatableFile* file = fSourceDomain->GetFile(directory, relativePath);
|
||||||
|
|
||||||
|
if (directory.Length() == 0 || relativePath[0] == '/')
|
||||||
|
_LocateFileIfMapped(relativePath, file);
|
||||||
|
else
|
||||||
|
_LocateFileIfMapped(BString(directory) << '/' << relativePath, file);
|
||||||
|
|
||||||
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -633,23 +640,27 @@ LocatableFile*
|
|||||||
FileManager::GetSourceFile(const BString& path)
|
FileManager::GetSourceFile(const BString& path)
|
||||||
{
|
{
|
||||||
AutoLocker<FileManager> locker(this);
|
AutoLocker<FileManager> locker(this);
|
||||||
return fSourceDomain->GetFile(path);
|
LocatableFile* file = fSourceDomain->GetFile(path);
|
||||||
|
_LocateFileIfMapped(path, file);
|
||||||
|
|
||||||
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
status_t
|
||||||
FileManager::SourceEntryLocated(const BString& path,
|
FileManager::SourceEntryLocated(const BString& path,
|
||||||
const BString& locatedPath)
|
const BString& locatedPath)
|
||||||
{
|
{
|
||||||
AutoLocker<FileManager> locker(this);
|
AutoLocker<FileManager> locker(this);
|
||||||
fSourceDomain->EntryLocated(path, locatedPath);
|
fSourceDomain->EntryLocated(path, locatedPath);
|
||||||
|
|
||||||
BMessage archivedMapping;
|
try {
|
||||||
if (archivedMapping.AddString("source:path", path) == B_OK
|
fSourceLocationMappings[path] = locatedPath;
|
||||||
&& archivedMapping.AddString("source:locatedpath", locatedPath)
|
} catch (...) {
|
||||||
== B_OK) {
|
return B_NO_MEMORY;
|
||||||
fLocationMappings.AddMessage("source:mapping", &archivedMapping);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -700,6 +711,8 @@ FileManager::LoadSourceFile(LocatableFile* file, SourceFile*& _sourceFile)
|
|||||||
status_t
|
status_t
|
||||||
FileManager::LoadLocationMappings(TeamFileManagerSettings* settings)
|
FileManager::LoadLocationMappings(TeamFileManagerSettings* settings)
|
||||||
{
|
{
|
||||||
|
AutoLocker<FileManager> locker(this);
|
||||||
|
|
||||||
for (int32 i = 0; i < settings->CountSourceMappings(); i++) {
|
for (int32 i = 0; i < settings->CountSourceMappings(); i++) {
|
||||||
BString sourcePath;
|
BString sourcePath;
|
||||||
BString locatedPath;
|
BString locatedPath;
|
||||||
@@ -707,7 +720,11 @@ FileManager::LoadLocationMappings(TeamFileManagerSettings* settings)
|
|||||||
if (settings->GetSourceMappingAt(i, sourcePath, locatedPath) != B_OK)
|
if (settings->GetSourceMappingAt(i, sourcePath, locatedPath) != B_OK)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
SourceEntryLocated(sourcePath, locatedPath);
|
try {
|
||||||
|
fSourceLocationMappings[sourcePath] = locatedPath;
|
||||||
|
} catch (...) {
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -717,7 +734,16 @@ FileManager::LoadLocationMappings(TeamFileManagerSettings* settings)
|
|||||||
status_t
|
status_t
|
||||||
FileManager::SaveLocationMappings(TeamFileManagerSettings* settings)
|
FileManager::SaveLocationMappings(TeamFileManagerSettings* settings)
|
||||||
{
|
{
|
||||||
return settings->SetTo(fLocationMappings);
|
AutoLocker<FileManager> locker(this);
|
||||||
|
|
||||||
|
for (LocatedFileMap::const_iterator it = fSourceLocationMappings.begin();
|
||||||
|
it != fSourceLocationMappings.end(); ++it) {
|
||||||
|
status_t error = settings->AddSourceMapping(it->first, it->second);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -747,3 +773,17 @@ FileManager::_SourceFileUnused(SourceFileEntry* entry)
|
|||||||
if (otherEntry == entry)
|
if (otherEntry == entry)
|
||||||
fSourceFiles->Remove(entry);
|
fSourceFiles->Remove(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
FileManager::_LocateFileIfMapped(const BString& sourcePath,
|
||||||
|
LocatableFile* file)
|
||||||
|
{
|
||||||
|
// called with lock held
|
||||||
|
LocatedFileMap::const_iterator it = fSourceLocationMappings.find(
|
||||||
|
sourcePath);
|
||||||
|
if (it != fSourceLocationMappings.end()
|
||||||
|
&& file->State() != LOCATABLE_ENTRY_LOCATED_EXPLICITLY) {
|
||||||
|
fSourceDomain->EntryLocated(it->first, it->second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#ifndef FILE_MANAGER_H
|
#ifndef FILE_MANAGER_H
|
||||||
#define FILE_MANAGER_H
|
#define FILE_MANAGER_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
@@ -43,7 +45,7 @@ public:
|
|||||||
// returns a reference
|
// returns a reference
|
||||||
LocatableFile* GetSourceFile(const BString& path);
|
LocatableFile* GetSourceFile(const BString& path);
|
||||||
// returns a reference
|
// returns a reference
|
||||||
void SourceEntryLocated(const BString& path,
|
status_t SourceEntryLocated(const BString& path,
|
||||||
const BString& locatedPath);
|
const BString& locatedPath);
|
||||||
|
|
||||||
status_t LoadSourceFile(LocatableFile* file,
|
status_t LoadSourceFile(LocatableFile* file,
|
||||||
@@ -65,6 +67,7 @@ private:
|
|||||||
typedef BOpenHashTable<EntryHashDefinition> LocatableEntryTable;
|
typedef BOpenHashTable<EntryHashDefinition> LocatableEntryTable;
|
||||||
typedef DoublyLinkedList<LocatableEntry> DeadEntryList;
|
typedef DoublyLinkedList<LocatableEntry> DeadEntryList;
|
||||||
typedef BOpenHashTable<SourceFileHashDefinition> SourceFileTable;
|
typedef BOpenHashTable<SourceFileHashDefinition> SourceFileTable;
|
||||||
|
typedef std::map<BString, BString> LocatedFileMap;
|
||||||
|
|
||||||
friend struct SourceFileEntry;
|
friend struct SourceFileEntry;
|
||||||
// for gcc 2
|
// for gcc 2
|
||||||
@@ -72,13 +75,16 @@ private:
|
|||||||
private:
|
private:
|
||||||
SourceFileEntry* _LookupSourceFile(const BString& path);
|
SourceFileEntry* _LookupSourceFile(const BString& path);
|
||||||
void _SourceFileUnused(SourceFileEntry* entry);
|
void _SourceFileUnused(SourceFileEntry* entry);
|
||||||
|
void _LocateFileIfMapped(const BString& sourcePath,
|
||||||
|
LocatableFile* file);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BLocker fLock;
|
BLocker fLock;
|
||||||
Domain* fTargetDomain;
|
Domain* fTargetDomain;
|
||||||
Domain* fSourceDomain;
|
Domain* fSourceDomain;
|
||||||
SourceFileTable* fSourceFiles;
|
SourceFileTable* fSourceFiles;
|
||||||
BMessage fLocationMappings;
|
|
||||||
|
LocatedFileMap fSourceLocationMappings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user