Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
performance
Megadep
Commits
bbbf361f
Commit
bbbf361f
authored
Jul 01, 2019
by
Pádraig Ó Conbhuí
Browse files
Fixed missing quiet flang in format.sh. Formatted and linted project.
parent
047f4c2e
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/megadep/megadep.cpp
View file @
bbbf361f
#include
<megadep/common_types.hpp>
#include
<megadep/megadep.hpp>
#include
<cerrno>
#include
<cstring>
#include
<dirent.h>
namespace
megadep
{
std
::
vector
<
FileName
>
list_files
(
const
DirectoryName
&
directory
)
{
namespace
fs
=
std
::
filesystem
;
std
::
vector
<
FileName
>
file_names
;
DIR
*
dir_ptr
;
...
...
@@ -17,7 +16,7 @@ std::vector<FileName> list_files(const DirectoryName &directory) {
dir_ptr
=
opendir
(
directory
.
c_str
());
// Directory is a file, return the directory name
if
(
dir_ptr
==
NULL
)
{
if
(
dir_ptr
==
nullptr
)
{
if
(
errno
==
ENOTDIR
||
errno
==
ENOENT
)
{
return
{
directory
};
}
...
...
@@ -25,17 +24,19 @@ std::vector<FileName> list_files(const DirectoryName &directory) {
return
{};
}
while
(
entity_ptr
=
readdir
(
dir_ptr
))
{
const
char
*
entity_name
=
entity_ptr
->
d_name
;
while
(
(
entity_ptr
=
readdir
(
dir_ptr
))
!=
nullptr
)
{
const
char
*
entity_name
=
static_cast
<
const
char
*>
(
entity_ptr
->
d_name
)
;
// Skip . and ..
if
(
strcmp
(
entity_name
,
"."
)
==
0
)
if
(
strcmp
(
entity_name
,
"."
)
==
0
)
{
continue
;
if
(
strcmp
(
entity_name
,
".."
)
==
0
)
}
if
(
strcmp
(
entity_name
,
".."
)
==
0
)
{
continue
;
}
// Try recursing
auto
sub_files
=
list_files
(
directory
+
'/'
+
entity_
ptr
->
d_
name
);
auto
sub_files
=
list_files
(
directory
+
'/'
+
entity_name
);
for
(
auto
&
sub_file
:
sub_files
)
{
file_names
.
emplace_back
(
std
::
move
(
sub_file
));
...
...
src/megadep/megadep.hpp
View file @
bbbf361f
...
...
@@ -8,8 +8,8 @@
namespace
megadep
{
std
::
vector
<
FileName
>
list_files
(
const
DirectoryName
&
director
ies
);
std
::
vector
<
FileName
>
list_files
(
const
DirectoryName
&
director
y
);
}
}
// namespace megadep
#endif // MEGADEP_MEGADEP_HPP
src/megadep/megadep.test.cpp
View file @
bbbf361f
...
...
@@ -2,10 +2,13 @@
#include
<megadep/megadep.hpp>
using
namespace
megadep
;
int
main
(
int
argc
,
char
*
argv
[])
{
auto
files
=
list_files
(
argv
[
1
]);
if
(
argc
!=
2
)
{
std
::
cout
<<
"Must provide directory argument!
\n
"
;
return
1
;
}
auto
files
=
megadep
::
list_files
(
argv
[
1
]);
// NOLINT
for
(
const
auto
&
file
:
files
)
{
std
::
cout
<<
file
<<
'\n'
;
}
...
...
tools/format.sh
View file @
bbbf361f
...
...
@@ -107,7 +107,7 @@ then
# If the formatted and unformatted files are the same, don't
# touch the original
if
!
cmp
"
${
tmpfile
}
"
"
${
target_file
}
"
if
!
cmp
--quiet
"
${
tmpfile
}
"
"
${
target_file
}
"
then
# Using cat instead of mv to preserve permissions etc.
cat
"
${
tmpfile
}
"
>
"
${
target_file
}
"
...
...
Write
Preview
Supports
Markdown
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