mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Add member data accessor for cache_t’s content filter function
This commit is contained in:
@@ -480,7 +480,8 @@ namespace
|
||||
for(auto path : bundles::locations())
|
||||
bundlesPaths.push_back(path::join(path, "Bundles"));
|
||||
bundlesIndexPath = path::join(path::home(), "Library/Caches/com.macromates.TextMate/BundlesIndex.plist");
|
||||
cache.load(bundlesIndexPath, &prune_dictionary);
|
||||
cache.set_content_filter(&prune_dictionary);
|
||||
cache.load(bundlesIndexPath);
|
||||
_needsCreateBundlesIndex = YES;
|
||||
[self createBundlesIndex:self];
|
||||
}
|
||||
|
||||
@@ -23,16 +23,12 @@ static std::string read_link (std::string const& path)
|
||||
return NULL_STR;
|
||||
}
|
||||
|
||||
static plist::dictionary_t dictionary_identity_function (plist::dictionary_t const& plist) { return plist; }
|
||||
|
||||
namespace plist
|
||||
{
|
||||
int32_t const cache_t::kPropertyCacheFormatVersion = 2;
|
||||
|
||||
void cache_t::load (std::string const& path, plist::dictionary_t (*prune_dictionary)(plist::dictionary_t const&))
|
||||
void cache_t::load (std::string const& path)
|
||||
{
|
||||
_prune_dictionary = prune_dictionary ?: dictionary_identity_function;
|
||||
|
||||
int32_t version;
|
||||
auto plist = plist::load(path);
|
||||
if(plist::get_key_path(plist, "version", version) && version == kPropertyCacheFormatVersion)
|
||||
@@ -290,7 +286,8 @@ namespace plist
|
||||
if(entry.is_file())
|
||||
{
|
||||
D(DBF_Plist_Cache, bug("load ‘%s’\n", path.c_str()););
|
||||
entry.set_content(_prune_dictionary(plist::load(path)));
|
||||
auto const content = plist::load(path);
|
||||
entry.set_content(_prune_dictionary ? _prune_dictionary(content) : content);
|
||||
entry.set_modified(buf.st_mtimespec.tv_sec);
|
||||
}
|
||||
else if(entry.is_directory())
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace plist
|
||||
{
|
||||
struct PUBLIC cache_t
|
||||
{
|
||||
void load (std::string const& path, plist::dictionary_t (*prune_dictionary)(plist::dictionary_t const&) = NULL);
|
||||
void load (std::string const& path);
|
||||
void save (std::string const& path) const;
|
||||
|
||||
bool dirty () const { return _dirty; }
|
||||
@@ -31,6 +31,9 @@ namespace plist
|
||||
return copy_links(_cache.find(path), out);
|
||||
}
|
||||
|
||||
void set_content_filter (plist::dictionary_t (*f)(plist::dictionary_t const&)) { _prune_dictionary = f; }
|
||||
plist::dictionary_t (*content_filter () const)(plist::dictionary_t const&) { return _prune_dictionary; }
|
||||
|
||||
private:
|
||||
static int32_t const kPropertyCacheFormatVersion;
|
||||
enum class entry_type_t { file, directory, link, missing, unknown };
|
||||
@@ -75,7 +78,7 @@ namespace plist
|
||||
std::vector<std::string> _entries;
|
||||
};
|
||||
|
||||
plist::dictionary_t (*_prune_dictionary)(plist::dictionary_t const&);
|
||||
plist::dictionary_t (*_prune_dictionary)(plist::dictionary_t const&) = nullptr;
|
||||
std::map<std::string, entry_t> _cache;
|
||||
bool _dirty = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user