Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
a06b5292
Commit
a06b5292
authored
Jul 01, 2017
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added select_oldest_file() and select_newest_file()
parent
0796ce79
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
0 deletions
+77
-0
dir_nav_extensions.cpp
dlib/dir_nav/dir_nav_extensions.cpp
+34
-0
dir_nav_extensions.h
dlib/dir_nav/dir_nav_extensions.h
+14
-0
dir_nav_extensions_abstract.h
dlib/dir_nav/dir_nav_extensions_abstract.h
+29
-0
No files found.
dlib/dir_nav/dir_nav_extensions.cpp
View file @
a06b5292
...
@@ -77,6 +77,40 @@ namespace dlib
...
@@ -77,6 +77,40 @@ namespace dlib
return
directory
(
f
.
full_name
().
substr
(
0
,
pos
));
return
directory
(
f
.
full_name
().
substr
(
0
,
pos
));
}
}
// ----------------------------------------------------------------------------------------
std
::
string
select_oldest_file
(
const
std
::
string
&
filename1
,
const
std
::
string
&
filename2
)
{
file
f1
,
f2
;
try
{
f1
=
file
(
filename1
);}
catch
(
file
::
file_not_found
&
)
{
return
filename1
;
}
try
{
f2
=
file
(
filename2
);}
catch
(
file
::
file_not_found
&
)
{
return
filename2
;
}
if
(
f1
.
last_modified
()
<
f2
.
last_modified
())
return
filename1
;
else
return
filename2
;
}
// ----------------------------------------------------------------------------------------
std
::
string
select_newest_file
(
const
std
::
string
&
filename1
,
const
std
::
string
&
filename2
)
{
file
f1
,
f2
;
try
{
f1
=
file
(
filename1
);}
catch
(
file
::
file_not_found
&
)
{
return
filename2
;
}
try
{
f2
=
file
(
filename2
);}
catch
(
file
::
file_not_found
&
)
{
return
filename1
;
}
if
(
f1
.
last_modified
()
>
f2
.
last_modified
())
return
filename1
;
else
return
filename2
;
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
}
...
...
dlib/dir_nav/dir_nav_extensions.h
View file @
a06b5292
...
@@ -146,6 +146,20 @@ namespace dlib
...
@@ -146,6 +146,20 @@ namespace dlib
const
file
&
f
const
file
&
f
);
);
// ----------------------------------------------------------------------------------------
std
::
string
select_oldest_file
(
const
std
::
string
&
filename1
,
const
std
::
string
&
filename2
);
// ----------------------------------------------------------------------------------------
std
::
string
select_newest_file
(
const
std
::
string
&
filename1
,
const
std
::
string
&
filename2
);
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
}
...
...
dlib/dir_nav/dir_nav_extensions_abstract.h
View file @
a06b5292
...
@@ -165,6 +165,35 @@ namespace dlib
...
@@ -165,6 +165,35 @@ namespace dlib
- returns a default initialized directory (i.e. directory())
- returns a default initialized directory (i.e. directory())
!*/
!*/
// ----------------------------------------------------------------------------------------
std
::
string
select_oldest_file
(
const
std
::
string
&
filename1
,
const
std
::
string
&
filename2
);
/*!
ensures
- Checks the last modification times of the two given files and returns the
filename of the oldest file, i.e., the file that has gone longest since being
modified. Ties are broken arbitrarily.
- For the purpose of comparison, a file that doesn't exist is presumed to have
a last modification time of -infinity (i.e. very far in the past).
!*/
// ----------------------------------------------------------------------------------------
std
::
string
select_newest_file
(
const
std
::
string
&
filename1
,
const
std
::
string
&
filename2
);
/*!
ensures
- Checks the last modification times of the two given files and returns the
filename that was most recently modified. Ties are broken arbitrarily.
- For the purpose of comparison, a file that doesn't exist is presumed to have
a last modification time of -infinity (i.e. very far in the past).
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
}
...
...
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