Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Simox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Leander Singer
Simox
Commits
95acfefc
Commit
95acfefc
authored
1 year ago
by
Fabian Tërnava
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://git.h2t.iar.kit.edu/sw/simox/simox
parents
876f14db
19ff02de
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SimoxUtility/filesystem/list_directory.cpp
+36
-16
36 additions, 16 deletions
SimoxUtility/filesystem/list_directory.cpp
SimoxUtility/filesystem/list_directory.h
+7
-2
7 additions, 2 deletions
SimoxUtility/filesystem/list_directory.h
with
43 additions
and
18 deletions
SimoxUtility/filesystem/list_directory.cpp
+
36
−
16
View file @
95acfefc
...
...
@@ -2,31 +2,51 @@
#include
<algorithm>
namespace
simox
{
std
::
vector
<
fs
::
path
>
fs
::
list_directory
(
const
path
&
directory
,
bool
local
,
bool
sort
)
namespace
impl
{
std
::
vector
<
path
>
entries
;
for
(
const
auto
&
entry
:
directory_iterator
(
directory
))
{
entries
.
push_back
(
entry
.
path
());
}
if
(
sort
)
{
std
::
sort
(
entries
.
begin
(),
entries
.
end
());
}
if
(
local
)
template
<
class
DirectoryIteratorT
>
std
::
vector
<
fs
::
path
>
list_directory
(
const
fs
::
path
&
directory
,
bool
local
,
bool
sort
)
{
for
(
auto
&
entry
:
entries
)
std
::
vector
<
fs
::
path
>
entries
;
for
(
const
auto
&
entry
:
DirectoryIteratorT
(
directory
))
{
entries
.
push_back
(
entry
.
path
());
}
if
(
sort
)
{
entry
=
entry
.
filename
(
);
std
::
sort
(
entries
.
begin
(),
entries
.
end
()
);
}
if
(
local
)
{
for
(
auto
&
entry
:
entries
)
{
entry
=
entry
.
filename
();
}
}
return
entries
;
}
return
entries
;
}
// namespace impl
std
::
vector
<
fs
::
path
>
fs
::
list_directory
(
const
path
&
directory
,
bool
local
,
bool
sort
)
{
return
impl
::
list_directory
<
std
::
filesystem
::
directory_iterator
>
(
directory
,
local
,
sort
);
}
}
std
::
vector
<
std
::
filesystem
::
__cxx11
::
path
>
fs
::
list_directory_recursive
(
const
path
&
directory
,
bool
local
,
bool
sort
)
{
return
impl
::
list_directory
<
std
::
filesystem
::
recursive_directory_iterator
>
(
directory
,
local
,
sort
);
}
}
// namespace simox
This diff is collapsed.
Click to expand it.
SimoxUtility/filesystem/list_directory.h
+
7
−
2
View file @
95acfefc
...
...
@@ -3,7 +3,6 @@
#include
<filesystem>
#include
<vector>
namespace
simox
::
fs
{
using
namespace
std
::
filesystem
;
...
...
@@ -18,5 +17,11 @@ namespace simox::fs
* @return The entries in `directory`.
*/
std
::
vector
<
path
>
list_directory
(
const
path
&
directory
,
bool
local
=
false
,
bool
sort
=
true
);
}
/**
* @brief Same as list_directory(), but recurses into subdirectories.
*/
std
::
vector
<
path
>
list_directory_recursive
(
const
path
&
directory
,
bool
local
=
false
,
bool
sort
=
true
);
}
// namespace simox::fs
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment