aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Fernando J. Pereda <ferdy@ferdyx.org> 2008-02-14 15:42:02 +0000
committerAvatar Fernando J. Pereda <ferdy@ferdyx.org> 2008-02-14 15:42:02 +0000
commit0fa9aeb48bf14b944958ba8a21a4876702456e29 (patch)
tree76084bda0733d711b0e2a1fb12e308f25f83ba70
parent3f23bc84239efb3917f47ff84fa43bca3aacd049 (diff)
downloadpaludis-0fa9aeb48bf14b944958ba8a21a4876702456e29.tar.gz
paludis-0fa9aeb48bf14b944958ba8a21a4876702456e29.tar.xz
Fix i-node sorting for DirIterator when there are two or more names for the same i-node in a directory.
-rw-r--r--paludis/util/dir_iterator.cc2
-rw-r--r--paludis/util/dir_iterator_TEST.cc7
-rwxr-xr-xpaludis/util/dir_iterator_TEST_setup.sh1
3 files changed, 9 insertions, 1 deletions
diff --git a/paludis/util/dir_iterator.cc b/paludis/util/dir_iterator.cc
index d001730..bbed09a 100644
--- a/paludis/util/dir_iterator.cc
+++ b/paludis/util/dir_iterator.cc
@@ -35,7 +35,7 @@ using namespace paludis;
#include <paludis/util/dir_iterator-se.cc>
-typedef std::set<std::pair<ino_t, FSEntry>, tr1::function<bool (std::pair<ino_t, FSEntry>, std::pair<ino_t, FSEntry>)> > EntrySet;
+typedef std::multiset<std::pair<ino_t, FSEntry>, tr1::function<bool (std::pair<ino_t, FSEntry>, std::pair<ino_t, FSEntry>)> > EntrySet;
namespace paludis
{
diff --git a/paludis/util/dir_iterator_TEST.cc b/paludis/util/dir_iterator_TEST.cc
index 2d010e6..57d876f 100644
--- a/paludis/util/dir_iterator_TEST.cc
+++ b/paludis/util/dir_iterator_TEST.cc
@@ -66,6 +66,7 @@ namespace test_cases
DirIterator iter(FSEntry("dir_iterator_TEST_dir"));
DirIterator iter1(FSEntry("dir_iterator_TEST_dir"));
DirIterator iter2(FSEntry("dir_iterator_TEST_dir"), DirIteratorOptions() + dio_include_dotfiles);
+ DirIterator iter3(FSEntry("dir_iterator_TEST_dir"), DirIteratorOptions() + dio_inode_sort);
TEST_CHECK(iter != DirIterator());
TEST_CHECK(DirIterator() != iter);
@@ -73,6 +74,8 @@ namespace test_cases
TEST_CHECK_EQUAL(iter->basename(), "file1");
TEST_CHECK(++iter != DirIterator());
TEST_CHECK_EQUAL(iter->basename(), "file2");
+ TEST_CHECK(++iter != DirIterator());
+ TEST_CHECK_EQUAL(iter->basename(), "file4");
TEST_CHECK(++iter == DirIterator());
TEST_CHECK(DirIterator() == iter);
@@ -86,12 +89,16 @@ namespace test_cases
TEST_CHECK_EQUAL(iter2->basename(), "file1");
TEST_CHECK(++iter2 != DirIterator());
TEST_CHECK_EQUAL(iter2->basename(), "file2");
+ TEST_CHECK(++iter2 != DirIterator());
+ TEST_CHECK_EQUAL(iter2->basename(), "file4");
TEST_CHECK(++iter2 == DirIterator());
TEST_CHECK(DirIterator() == iter2);
TEST_CHECK(iter2 == DirIterator());
TEST_CHECK(iter1 == iter2);
TEST_CHECK(iter2 == iter1);
+
+ TEST_CHECK_EQUAL(std::distance(iter3, DirIterator()), 3);
}
} test_dir_iterator_iterate;
}
diff --git a/paludis/util/dir_iterator_TEST_setup.sh b/paludis/util/dir_iterator_TEST_setup.sh
index 930f2f5..4855cc7 100755
--- a/paludis/util/dir_iterator_TEST_setup.sh
+++ b/paludis/util/dir_iterator_TEST_setup.sh
@@ -4,3 +4,4 @@
mkdir dir_iterator_TEST_dir || exit 2
cd dir_iterator_TEST_dir || exit 3
touch file1 file2 .file3 || exit 4
+ln file1 file4 || exit 5