Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
dbaee9f9
Commit
dbaee9f9
authored
Oct 03, 2010
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added 'file_modified_time' function, which should be faster than using wxFileName
parent
41ff4fb6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
6 deletions
+27
-6
src/util/file_utils.cpp
src/util/file_utils.cpp
+17
-0
src/util/file_utils.hpp
src/util/file_utils.hpp
+7
-2
src/util/io/package.cpp
src/util/io/package.cpp
+3
-4
No files found.
src/util/file_utils.cpp
View file @
dbaee9f9
...
@@ -10,6 +10,8 @@
...
@@ -10,6 +10,8 @@
#include <util/file_utils.hpp>
#include <util/file_utils.hpp>
#include <wx/filename.h>
#include <wx/filename.h>
#include <wx/dir.h>
#include <wx/dir.h>
#include <errno.h>
#include <sys/stat.h>
DECLARE_TYPEOF_COLLECTION
(
String
);
DECLARE_TYPEOF_COLLECTION
(
String
);
...
@@ -88,6 +90,21 @@ bool resolve_filename_conflicts(wxFileName& fn, FilenameConflicts conflicts, set
...
@@ -88,6 +90,21 @@ bool resolve_filename_conflicts(wxFileName& fn, FilenameConflicts conflicts, set
}
}
}
}
// ----------------------------------------------------------------------------- : File info
time_t
file_modified_time
(
const
String
&
path
)
{
// Note: wxFileName also provides a function for this, but that is very slow.
struct
stat
statbuf
;
if
(
stat
(
path
.
mb_str
(),
&
statbuf
)
!=
0
)
{
if
(
errno
==
ENOENT
)
{
return
0
;
}
else
{
throw
InternalError
(
_
(
"could not stat "
)
+
path
);
}
}
return
statbuf
.
st_mtime
;
}
// ----------------------------------------------------------------------------- : Directories
// ----------------------------------------------------------------------------- : Directories
bool
create_parent_dirs
(
const
String
&
file
)
{
bool
create_parent_dirs
(
const
String
&
file
)
{
...
...
src/util/file_utils.hpp
View file @
dbaee9f9
...
@@ -4,8 +4,8 @@
...
@@ -4,8 +4,8 @@
//| License: GNU General Public License 2 or later (see file COPYING) |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
//+----------------------------------------------------------------------------+
#ifndef HEADER_UTIL_FILE_UTILS
#ifndef HEADER_UTIL_FILE_UTILS
#define HEADER_UTIL_FILE_UTILS
#define HEADER_UTIL_FILE_UTILS
// ----------------------------------------------------------------------------- : Includes
// ----------------------------------------------------------------------------- : Includes
...
@@ -32,6 +32,11 @@ String clean_filename(const String& name);
...
@@ -32,6 +32,11 @@ String clean_filename(const String& name);
/** Returns true if the filename should be used, false if failed. */
/** Returns true if the filename should be used, false if failed. */
bool
resolve_filename_conflicts
(
wxFileName
&
fn
,
FilenameConflicts
conflicts
,
set
<
String
>&
used
);
bool
resolve_filename_conflicts
(
wxFileName
&
fn
,
FilenameConflicts
conflicts
,
set
<
String
>&
used
);
// ----------------------------------------------------------------------------- : File info
/// Get the last modified time of a file
time_t
file_modified_time
(
const
String
&
name
);
// ----------------------------------------------------------------------------- : Removing and renaming
// ----------------------------------------------------------------------------- : Removing and renaming
/// Ensure that the parent directories of the given filename exist
/// Ensure that the parent directories of the given filename exist
...
...
src/util/io/package.cpp
View file @
dbaee9f9
...
@@ -349,12 +349,11 @@ void Package::openSubdir(const String& name) {
...
@@ -349,12 +349,11 @@ void Package::openSubdir(const String& name) {
String
f
;
// filename
String
f
;
// filename
for
(
bool
ok
=
d
.
GetFirst
(
&
f
,
wxEmptyString
,
wxDIR_FILES
|
wxDIR_HIDDEN
)
;
ok
;
ok
=
d
.
GetNext
(
&
f
))
{
for
(
bool
ok
=
d
.
GetFirst
(
&
f
,
wxEmptyString
,
wxDIR_FILES
|
wxDIR_HIDDEN
)
;
ok
;
ok
=
d
.
GetNext
(
&
f
))
{
if
(
ignore_file
(
f
))
continue
;
if
(
ignore_file
(
f
))
continue
;
// add file
// add file
to list of known files
addFile
(
name
+
f
);
addFile
(
name
+
f
);
// get modified time
// get modified time
wxFileName
fn
(
filename
+
_
(
"/"
)
+
name
+
f
);
wxDateTime
file_time
=
file_modified_time
(
filename
+
_
(
"/"
)
+
name
+
f
);
wxDateTime
mod
;
modified
=
max
(
modified
,
file_time
);
if
(
fn
.
GetTimes
(
0
,
&
mod
,
0
)
&&
mod
>
modified
)
modified
=
mod
;
}
}
// find subdirs
// find subdirs
for
(
bool
ok
=
d
.
GetFirst
(
&
f
,
wxEmptyString
,
wxDIR_DIRS
|
wxDIR_HIDDEN
)
;
ok
;
ok
=
d
.
GetNext
(
&
f
))
{
for
(
bool
ok
=
d
.
GetFirst
(
&
f
,
wxEmptyString
,
wxDIR_DIRS
|
wxDIR_HIDDEN
)
;
ok
;
ok
=
d
.
GetNext
(
&
f
))
{
...
...
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