status_t FileManager::LoadSourceFile(LocatableFile* file, SourceFile*& _sourceFile) { AutoLocker<FileManager> locker(this); // get the path BString path; BString originalPath; file->GetPath(originalPath); if (!file->GetLocatedPath(path)) { // see if this is a file we have a lazy mapping for. if (!_LocateFileIfMapped(originalPath, file) || !file->GetLocatedPath(path)) { return B_ENTRY_NOT_FOUND; } } // we might already know the source file SourceFileEntry* entry = _LookupSourceFile(originalPath); if (entry != NULL) { entry->file->AcquireReference(); _sourceFile = entry->file; return B_OK; } // create the hash table entry entry = new(std::nothrow) SourceFileEntry(this, originalPath); if (entry == NULL) return B_NO_MEMORY; // load the file SourceFile* sourceFile = new(std::nothrow) SourceFile(entry); if (sourceFile == NULL) { delete entry; return B_NO_MEMORY; } ObjectDeleter<SourceFile> sourceFileDeleter(sourceFile); entry->file = sourceFile; status_t error = sourceFile->Init(path); if (error != B_OK) return error; fSourceFiles->Insert(entry); _sourceFile = sourceFileDeleter.Detach(); return B_OK; }