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
7ca0977b
Commit
7ca0977b
authored
May 02, 2015
by
Hugo Beauzée-Luyssen
Browse files
IFile: expose file last modification date
parent
e1146135
Changes
3
Show whitespace changes
Inline
Side-by-side
src/filesystem/IFile.h
View file @
7ca0977b
...
...
@@ -15,5 +15,6 @@ namespace fs
/// Returns the entire path, plus filename
virtual
const
std
::
string
&
fullPath
()
const
=
0
;
virtual
const
std
::
string
&
extension
()
const
=
0
;
virtual
unsigned
int
lastModificationDate
()
const
=
0
;
};
}
src/filesystem/unix/File.cpp
View file @
7ca0977b
#include "File.h"
#include "Utils.h"
#include <stdexcept>
#include <sys/stat.h>
namespace
fs
{
...
...
@@ -10,6 +13,10 @@ File::File( const std::string& path, const std::string& fileName )
,
m_fullPath
(
path
+
(
*
path
.
rbegin
()
!=
'/'
?
"/"
:
""
)
+
fileName
)
,
m_extension
(
utils
::
file
::
extension
(
fileName
)
)
{
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
;
}
const
std
::
string
&
File
::
name
()
const
...
...
@@ -32,4 +39,9 @@ const std::string& File::extension() const
return
m_extension
;
}
unsigned
int
File
::
lastModificationDate
()
const
{
return
m_lastModificationDate
;
}
}
src/filesystem/unix/File.h
View file @
7ca0977b
...
...
@@ -17,12 +17,14 @@ public:
virtual
const
std
::
string
&
path
()
const
override
;
virtual
const
std
::
string
&
fullPath
()
const
override
;
virtual
const
std
::
string
&
extension
()
const
override
;
virtual
unsigned
int
lastModificationDate
()
const
override
;
private:
const
std
::
string
m_path
;
const
std
::
string
m_name
;
const
std
::
string
m_fullPath
;
const
std
::
string
m_extension
;
unsigned
int
m_lastModificationDate
;
};
}
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