Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
2acd12c7
Commit
2acd12c7
authored
Mar 10, 2016
by
Hugo Beauzée-Luyssen
Browse files
fs: unix: Simplify and don't call twice on the same file
parent
b3b89327
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/filesystem/unix/Directory.cpp
View file @
2acd12c7
...
...
@@ -112,10 +112,6 @@ void Directory::read() const
}
std
::
string
path
=
m_path
+
"/"
+
result
->
d_name
;
#if defined(_DIRENT_HAVE_D_TYPE) && defined(_BSD_SOURCE)
if
(
result
->
d_type
==
DT_DIR
)
{
#else
struct
stat
s
;
if
(
lstat
(
path
.
c_str
(),
&
s
)
!=
0
)
{
...
...
@@ -128,7 +124,6 @@ void Directory::read() const
}
if
(
S_ISDIR
(
s
.
st_mode
)
)
{
#endif
auto
dirPath
=
toAbsolute
(
path
);
if
(
*
dirPath
.
crbegin
()
!=
'/'
)
dirPath
+=
'/'
;
...
...
@@ -138,7 +133,7 @@ void Directory::read() const
else
{
auto
filePath
=
toAbsolute
(
path
);
m_files
.
emplace_back
(
std
::
make_shared
<
File
>
(
filePath
)
);
m_files
.
emplace_back
(
std
::
make_shared
<
File
>
(
filePath
,
s
)
);
}
}
}
...
...
src/filesystem/unix/File.cpp
View file @
2acd12c7
...
...
@@ -28,12 +28,9 @@
namespace
fs
{
File
::
File
(
const
std
::
string
&
filePath
)
File
::
File
(
const
std
::
string
&
filePath
,
const
struct
stat
&
s
)
:
CommonFile
(
filePath
)
{
struct
stat
s
;
if
(
lstat
(
m_fullPath
.
c_str
(),
&
s
)
)
throw
std
::
runtime_error
(
"Failed to get file stats"
);
m_lastModificationDate
=
s
.
st_mtim
.
tv_sec
;
}
...
...
src/filesystem/unix/File.h
View file @
2acd12c7
...
...
@@ -24,13 +24,15 @@
#include "filesystem/common/CommonFile.h"
struct
stat
;
namespace
fs
{
class
File
:
public
CommonFile
{
public:
explicit
File
(
const
std
::
string
&
filePath
);
explicit
File
(
const
std
::
string
&
filePath
,
const
struct
stat
&
s
);
virtual
unsigned
int
lastModificationDate
()
const
override
;
...
...
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