aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-22 17:11:50 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-22 18:55:23 +0100
commit84f32a46c9bd03039af31be9626206ce891fa841 (patch)
tree08ab21ab85a7735b6661619ab8a03ac489bb1efd
parent7a8a792ae878e2b432e0c67a813022117faa4e60 (diff)
downloadpaludis-84f32a46c9bd03039af31be9626206ce891fa841.tar.gz
paludis-84f32a46c9bd03039af31be9626206ce891fa841.tar.xz
Can't force the return type
-rw-r--r--paludis/util/dir_iterator.cc30
1 files changed, 16 insertions, 14 deletions
diff --git a/paludis/util/dir_iterator.cc b/paludis/util/dir_iterator.cc
index 11e2c8d..94448fe 100644
--- a/paludis/util/dir_iterator.cc
+++ b/paludis/util/dir_iterator.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2010 Ciaran McCreesh
* Copyright (c) 2008 Fernando J. Pereda
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -51,11 +51,21 @@ namespace paludis
std::shared_ptr<EntrySet> items;
EntrySet::iterator iter;
- Implementation(std::shared_ptr<EntrySet> ii) :
+ Implementation(const std::shared_ptr<EntrySet> & ii) :
items(ii)
{
}
};
+
+ bool compare_inode(const std::pair<ino_t, FSEntry> & a, const std::pair<ino_t, FSEntry> & b)
+ {
+ return a.first < b.first;
+ }
+
+ bool compare_name(const std::pair<ino_t, FSEntry> & a, const std::pair<ino_t, FSEntry> & b)
+ {
+ return a.second < b.second;
+ }
}
DirOpenError::DirOpenError(const FSEntry & location, const int errno_value) throw () :
@@ -64,22 +74,14 @@ DirOpenError::DirOpenError(const FSEntry & location, const int errno_value) thro
}
DirIterator::DirIterator(const FSEntry & base, const DirIteratorOptions & options) :
- PrivateImplementationPattern<DirIterator>(new Implementation<DirIterator>(std::shared_ptr<EntrySet>(new EntrySet)))
+ PrivateImplementationPattern<DirIterator>(new Implementation<DirIterator>(std::shared_ptr<EntrySet>()))
{
using namespace std::placeholders;
if (options[dio_inode_sort])
- _imp->items.reset(new EntrySet(
- std::bind(std::less<ino_t>(),
- std::bind<ino_t>(std::mem_fn(&std::pair<ino_t, FSEntry>::first), _1),
- std::bind<ino_t>(std::mem_fn(&std::pair<ino_t, FSEntry>::first), _2))
- ));
+ _imp->items = std::make_shared<EntrySet>(&compare_inode);
else
- _imp->items.reset(new EntrySet(
- std::bind(std::less<FSEntry>(),
- std::bind<FSEntry>(std::mem_fn(&std::pair<ino_t, FSEntry>::second), _1),
- std::bind<FSEntry>(std::mem_fn(&std::pair<ino_t, FSEntry>::second), _2))
- ));
+ _imp->items = std::make_shared<EntrySet>(&compare_name);
DIR * d(opendir(stringify(base).c_str()));
if (0 == d)
@@ -126,7 +128,7 @@ DirIterator::DirIterator(const DirIterator & other) :
}
DirIterator::DirIterator() :
- PrivateImplementationPattern<DirIterator>(new Implementation<DirIterator>(std::shared_ptr<EntrySet>(new EntrySet)))
+ PrivateImplementationPattern<DirIterator>(new Implementation<DirIterator>(std::shared_ptr<EntrySet>(new EntrySet(&compare_name))))
{
_imp->iter = _imp->items->end();
}