Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
b8d0765f
Commit
b8d0765f
authored
May 01, 2017
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kj::Directory::list*() should return sorted lists to avoid non-determinism.
parent
7185b54a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
2 deletions
+16
-2
filesystem-disk.c++
c++/src/kj/filesystem-disk.c++
+6
-2
filesystem.c++
c++/src/kj/filesystem.c++
+4
-0
filesystem.h
c++/src/kj/filesystem.h
+6
-0
No files found.
c++/src/kj/filesystem-disk.c++
View file @
b8d0765f
...
...
@@ -34,6 +34,7 @@
#include <stdlib.h>
#include "vector.h"
#include "miniposix.h"
#include <algorithm>
#if __linux__
#include <linux/fs.h>
...
...
@@ -599,7 +600,8 @@ public:
}
KJ_DEFER
(
closedir
(
dir
));
kj
::
Vector
<
Decay
<
decltype
(
func
(
instance
<
StringPtr
>
(),
instance
<
FsNode
::
Type
>
()))
>>
entries
;
typedef
Decay
<
decltype
(
func
(
instance
<
StringPtr
>
(),
instance
<
FsNode
::
Type
>
()))
>
Entry
;
kj
::
Vector
<
Entry
>
entries
;
for
(;;)
{
errno
=
0
;
...
...
@@ -634,7 +636,9 @@ public:
}
}
return
entries
.
releaseAsArray
();
auto
result
=
entries
.
releaseAsArray
();
std
::
sort
(
result
.
begin
(),
result
.
end
());
return
result
;
}
Array
<
String
>
listNames
()
{
...
...
c++/src/kj/filesystem.c++
View file @
b8d0765f
...
...
@@ -1287,7 +1287,11 @@ private:
};
Clock
&
clock
;
std
::
map
<
StringPtr
,
EntryImpl
>
entries
;
// Note: If this changes to a non-sorted map, listNames() and listEntries() must be updated to
// sort their results.
Date
lastModified
;
template
<
typename
T
>
...
...
c++/src/kj/filesystem.h
View file @
b8d0765f
...
...
@@ -426,6 +426,12 @@ public:
struct
Entry
{
FsNode
::
Type
type
;
String
name
;
inline
bool
operator
<
(
const
Entry
&
other
)
const
{
return
name
<
other
.
name
;
}
inline
bool
operator
>
(
const
Entry
&
other
)
const
{
return
name
>
other
.
name
;
}
inline
bool
operator
<=
(
const
Entry
&
other
)
const
{
return
name
<=
other
.
name
;
}
inline
bool
operator
>=
(
const
Entry
&
other
)
const
{
return
name
>=
other
.
name
;
}
// Convenience comparison operators to sort entries by name.
};
virtual
Array
<
Entry
>
listEntries
()
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment