mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 09:09:40 +00:00
Updated components/misc/timeconvert.hpp to fix the Android build.
This commit is contained in:
parent
5446571aec
commit
35fe214588
12 changed files with 27 additions and 27 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <components/misc/strings/format.hpp>
|
||||
#include <components/misc/strings/lower.hpp>
|
||||
#include <components/esm3/esmreader.hpp>
|
||||
#include <components/misc/timeconvert.hpp>
|
||||
|
||||
|
||||
|
||||
|
@ -990,7 +991,7 @@ std::time_t MwIniImporter::lastWriteTime(const std::filesystem::path& filename,
|
|||
if (std::filesystem::exists(filename))
|
||||
{
|
||||
std::filesystem::path resolved = std::filesystem::canonical(filename);
|
||||
writeTime = std::chrono::system_clock::to_time_t (Misc::clockCast<std::chrono::system_clock::time_point> (std::filesystem::last_write_time (resolved)));;
|
||||
writeTime = Misc::to_time_t(std::filesystem::last_write_time (resolved));
|
||||
|
||||
// print timestamp
|
||||
const int size=1024;
|
||||
|
|
|
@ -47,13 +47,13 @@ private:
|
|||
OpenMW application stack assumes UTF-8 encoding, therefore this
|
||||
conversion.
|
||||
|
||||
For std::filesystem::path::imbue see components/files/windowspath.cpp
|
||||
For boost::filesystem::path::imbue see components/files/windowspath.cpp
|
||||
*/
|
||||
int wmain(int argc, wchar_t *wargv[]) {
|
||||
utf8argv converter(argc, wargv);
|
||||
char **argv = converter.get();
|
||||
// TODO(Project579): Temporarly disabled until a good solution is found (no solution might actually be needed)
|
||||
//std::filesystem::path::imbue(boost::locale::generator().generate(""));
|
||||
//boost::filesystem::path::imbue(boost::locale::generator().generate(""));
|
||||
#endif
|
||||
|
||||
try
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
#include "adjusterwidget.hpp"
|
||||
|
||||
#ifndef CS_QT_BOOST_FILESYSTEM_PATH_DECLARED
|
||||
#define CS_QT_BOOST_FILESYSTEM_PATH_DECLARED
|
||||
#ifndef CS_QT_STD_FILESYSTEM_PATH_DECLARED
|
||||
#define CS_QT_STD_FILESYSTEM_PATH_DECLARED
|
||||
Q_DECLARE_METATYPE (std::filesystem::path)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#include <filesystem>
|
||||
|
||||
#ifndef CS_QT_BOOST_FILESYSTEM_PATH_DECLARED
|
||||
#define CS_QT_BOOST_FILESYSTEM_PATH_DECLARED
|
||||
#ifndef CS_QT_STD_FILESYSTEM_PATH_DECLARED
|
||||
#define CS_QT_STD_FILESYSTEM_PATH_DECLARED
|
||||
Q_DECLARE_METATYPE (std::filesystem::path)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
|
||||
#include <QWidget>
|
||||
|
||||
#ifndef Q_MOC_RUN
|
||||
#include <filesystem>
|
||||
#endif
|
||||
|
||||
class QPushButton;
|
||||
class QListWidget;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <components/settings/settings.hpp>
|
||||
|
||||
#include <components/files/memorystream.hpp>
|
||||
#include <components/misc/timeconvert.hpp>
|
||||
|
||||
#include <components/esm3/loadclas.hpp>
|
||||
|
||||
|
@ -403,7 +404,7 @@ namespace MWGui
|
|||
throw std::runtime_error("Can't find selected slot");
|
||||
|
||||
std::stringstream text;
|
||||
time_t time = mCurrentSlot->mTimeStamp;
|
||||
time_t time = Misc::to_time_t(mCurrentSlot->mTimeStamp);
|
||||
struct tm* timeinfo;
|
||||
timeinfo = localtime(&time);
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <components/esm/defs.hpp>
|
||||
#include <components/esm3/esmreader.hpp>
|
||||
#include <components/misc/utf8stream.hpp>
|
||||
#include <components/misc/timeconvert.hpp>
|
||||
|
||||
#include <components/misc/strings/algorithm.hpp>
|
||||
|
||||
|
@ -31,7 +30,7 @@ void MWState::Character::addSlot (const std::filesystem::path& path, const std::
|
|||
{
|
||||
Slot slot;
|
||||
slot.mPath = path;
|
||||
slot.mTimeStamp = std::chrono::system_clock::to_time_t (Misc::clockCast<std::chrono::system_clock::time_point> (std::filesystem::last_write_time (path)));
|
||||
slot.mTimeStamp = std::filesystem::last_write_time (path);
|
||||
|
||||
ESM::ESMReader reader;
|
||||
reader.open (slot.mPath.string());
|
||||
|
@ -78,7 +77,7 @@ void MWState::Character::addSlot (const ESM::SavedGame& profile)
|
|||
}
|
||||
|
||||
slot.mProfile = profile;
|
||||
slot.mTimeStamp = std::time (nullptr);
|
||||
slot.mTimeStamp = std::filesystem::file_time_type ();
|
||||
|
||||
mSlots.push_back (slot);
|
||||
}
|
||||
|
@ -156,7 +155,7 @@ const MWState::Slot *MWState::Character::updateSlot (const Slot *slot, const ESM
|
|||
|
||||
Slot newSlot = *slot;
|
||||
newSlot.mProfile = profile;
|
||||
newSlot.mTimeStamp = std::time (nullptr);
|
||||
newSlot.mTimeStamp = std::filesystem::file_time_type ();
|
||||
|
||||
mSlots.erase (mSlots.begin()+index);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace MWState
|
|||
{
|
||||
std::filesystem::path mPath;
|
||||
ESM::SavedGame mProfile;
|
||||
std::time_t mTimeStamp;
|
||||
std::filesystem::file_time_type mTimeStamp;
|
||||
};
|
||||
|
||||
bool operator< (const Slot& left, const Slot& right);
|
||||
|
|
|
@ -173,7 +173,7 @@ bool Config::GameSettings::writeFile(QTextStream &stream)
|
|||
while (i.hasPrevious()) {
|
||||
i.previous();
|
||||
|
||||
// path lines (e.g. 'data=...') need quotes and ampersands escaping to match how std::filesystem::path uses boost::io::quoted
|
||||
// path lines (e.g. 'data=...') need quotes and ampersands escaping to match how boost::filesystem::path uses boost::io::quoted
|
||||
if (i.key() == QLatin1String("data")
|
||||
|| i.key() == QLatin1String("data-local")
|
||||
|| i.key() == QLatin1String("resources")
|
||||
|
|
|
@ -427,7 +427,7 @@ void parseConfig(std::istream& stream, bpo::variables_map& variables, const bpo:
|
|||
|
||||
std::istream& operator>> (std::istream& istream, MaybeQuotedPath& MaybeQuotedPath)
|
||||
{
|
||||
// If the stream starts with a double quote, read from stream using std::filesystem::path rules, then discard anything remaining.
|
||||
// If the stream starts with a double quote, read from stream using boost::filesystem::path rules, then discard anything remaining.
|
||||
// This prevents boost::program_options getting upset that we've not consumed the whole stream.
|
||||
// If it doesn't start with a double quote, read the whole thing verbatim
|
||||
if (istream.peek() == '"')
|
||||
|
|
|
@ -38,10 +38,10 @@ WindowsPath::WindowsPath(const std::string& application_name)
|
|||
with UTF-8 encoding (generated for empty name from boost::locale)
|
||||
to handle Unicode in platform-agnostic way using std::string.
|
||||
|
||||
See std::filesystem and boost::locale reference for details.
|
||||
See boost::filesystem and boost::locale reference for details.
|
||||
*/
|
||||
// TODO(Project579): Temporarly disabled until a good solution is found (no solution might actually be needed)
|
||||
//std::filesystem::path::imbue(boost::locale::generator().generate(""));
|
||||
//boost::filesystem::path::imbue(boost::locale::generator().generate(""));
|
||||
|
||||
std::filesystem::path localPath = getLocalPath();
|
||||
if (!SetCurrentDirectoryA(localPath.string().c_str()))
|
||||
|
@ -111,7 +111,7 @@ std::filesystem::path WindowsPath::getCachePath() const
|
|||
|
||||
std::filesystem::path WindowsPath::getInstallPath() const
|
||||
{
|
||||
std::filesystem::path installPath("");
|
||||
std::filesystem::path installPath();
|
||||
|
||||
HKEY hKey;
|
||||
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
#ifndef OPENMW_COMPONENTS_MISC_TIMECONVERT_H
|
||||
#define OPENMW_COMPONENTS_MISC_TIMECONVERT_H
|
||||
|
||||
#include <ctime>
|
||||
#include <chrono>
|
||||
|
||||
namespace Misc
|
||||
{
|
||||
// Very ugly hack to go from std::chrono::file_clock to any other clock, can be replaced with better solution in C++20
|
||||
// https://stackoverflow.com/questions/35282308/convert-between-c11-clocks
|
||||
template <typename DstTimePointT, typename SrcTimePointT, typename DstClockT = typename DstTimePointT::clock, typename SrcClockT = typename SrcTimePointT::clock>
|
||||
inline DstTimePointT clockCast (const SrcTimePointT tp)
|
||||
template <typename TP>
|
||||
inline std::time_t to_time_t(TP tp)
|
||||
{
|
||||
const auto src_now = SrcClockT::now();
|
||||
const auto dst_now = DstClockT::now();
|
||||
return dst_now + (tp - src_now);
|
||||
using namespace std::chrono;
|
||||
auto sctp = time_point_cast<system_clock::duration>(tp - TP::clock::now() + system_clock::now());
|
||||
return system_clock::to_time_t(sctp);
|
||||
}
|
||||
} // namespace Misc
|
||||
|
||||
|
|
Loading…
Reference in a new issue