Jamie Reece Wilson
83f34b0c47
03:28:55:638 17>2 of 53388 functions (<0.1%) were compiled, the rest were copied from previous compilation. 03:28:55:638 17> 0 functions were new in current compilation 03:28:55:638 17> 65 functions had inline decision re-evaluated but remain unchanged 03:28:56:749 17>Finished generating code the header of const AuString & is the same as std::string_view therefore nothing changes. in fact, we still need to alloc strings a bunch of times for a zero terminated string. worse, <c++20 always allocs each time we want to access a hashmap with o(1) lookup, making small hashmaps kinda pointless when we always have to alloc+copy (thx std) perhaps this will help some language binders
82 lines
1.9 KiB
C++
82 lines
1.9 KiB
C++
/***
|
|
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: FSTimes.Unix.cpp
|
|
Date: 2023-2-4
|
|
Author: Reece
|
|
***/
|
|
#include <Source/RuntimeInternal.hpp>
|
|
#include "FS.hpp"
|
|
#include "FSTimes.Unix.hpp"
|
|
#include <Source/Time/Time.hpp>
|
|
#include <sys/time.h>
|
|
#include <utime.h>
|
|
|
|
namespace Aurora::IO::FS
|
|
{
|
|
void ConvertFileTime(timeval *temp,
|
|
AuInt64 alternative,
|
|
AuOptionalEx<AuInt64> time)
|
|
{
|
|
timespec ts;
|
|
|
|
if (!time)
|
|
{
|
|
time = alternative;
|
|
}
|
|
|
|
AuTime::auabsns2ts(&ts, time.value());
|
|
|
|
temp->tv_sec = ts.tv_sec;
|
|
temp->tv_usec = ts.tv_nsec / 1'000ull;
|
|
}
|
|
|
|
AUKN_SYM bool UpdateFileTimes(const AuROString &path, const UpdateTimes ×)
|
|
{
|
|
if (times.createdNs)
|
|
{
|
|
SysPushErrorArg("Cannot modify a files' created timestamp under UNIX");
|
|
return false;
|
|
}
|
|
|
|
auto pathex = NormalizePathRet(path);
|
|
if (pathex.empty())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
RuntimeWaitForSecondaryTick();
|
|
|
|
Stat auStat;
|
|
if (!times.accessedNs ||
|
|
!times.modifiedNs)
|
|
{
|
|
if (!AuFS::StatFile(pathex, auStat))
|
|
{
|
|
SysPushErrorArg("Cannot stat file of a attr-poke suspect");
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!AuFS::FileExists(pathex))
|
|
{
|
|
SysPushErrorIO("Missing file: {}", path);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
timeval timeVals[2];
|
|
|
|
ConvertFileTime(&timeVals[0], auStat.accessedNs, times.accessedNs);
|
|
ConvertFileTime(&timeVals[1], auStat.modifiedNs, times.modifiedNs);
|
|
|
|
bool bRet = ::utimes(pathex.c_str(), timeVals) == 0;
|
|
if (!bRet)
|
|
{
|
|
SysPushErrorIO();
|
|
}
|
|
|
|
return bRet;
|
|
}
|
|
} |