mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
added 'file_modified_time' function, which should be faster than using wxFileName
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1519 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
#include <util/file_utils.hpp>
|
||||
#include <wx/filename.h>
|
||||
#include <wx/dir.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
DECLARE_TYPEOF_COLLECTION(String);
|
||||
|
||||
@@ -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
|
||||
|
||||
bool create_parent_dirs(const String& file) {
|
||||
|
||||
Reference in New Issue
Block a user