[*] I was right. String views are [mostly] pointless (*)

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
This commit is contained in:
Reece Wilson 2024-04-19 04:33:57 +01:00
parent 616fc54531
commit 83f34b0c47
57 changed files with 420 additions and 356 deletions

View File

@ -21,14 +21,14 @@ namespace Aurora::CmdLine
* @param key
* @return
*/
AUKN_SYM bool HasFlag(const AuString &key);
AUKN_SYM bool HasFlag(const AuROString &key);
/**
* @brief Performs a check on whether such string came before an equals sign
* @param key
* @return
*/
AUKN_SYM bool HasValue(const AuString &key);
AUKN_SYM bool HasValue(const AuROString &key);
/**
* @brief Returns part after key= or defaultDefault
@ -36,14 +36,14 @@ namespace Aurora::CmdLine
* @param defaultValue
* @return
*/
AUKN_SYM const AuString &GetValue(const AuString &key, const AuString &defaultValue);
AUKN_SYM const AuString &GetValue(const AuROString &key, const AuString &defaultValue);
/**
* @brief Returns part after key=
* @param key
* @return
*/
AUKN_SYM AuOptional<const AuString &> GetValue(const AuString &key);
AUKN_SYM AuOptional<const AuString &> GetValue(const AuROString &key);
/**
* @brief Returns a constant array of values; key=values and /key values
@ -51,7 +51,7 @@ namespace Aurora::CmdLine
* @return
* @warning multiple of @param key must exist
*/
AUKN_SYM const AuList<AuString> &GetValues(const AuString &key);
AUKN_SYM const AuList<AuString> &GetValues(const AuROString &key);
/**
* @brief Returns a constant array of flag keys

View File

@ -17,22 +17,22 @@ namespace Aurora::Async
namespace Aurora::Console::Commands
{
AUKN_SYM void AddCommand(const AuString &tag, const Parse::ParseObject &commandStructure, const AuSPtr<ICommandSubscriber> &subscriber);
AUKN_SYM void AddCommand(const AuROString &tag, const Parse::ParseObject &commandStructure, const AuSPtr<ICommandSubscriber> &subscriber);
AUKN_SYM void RemoveCommand(const AuString &tag);
AUKN_SYM void RemoveCommand(const AuROString &tag);
/**
* Dispatch a command to the main thread or aurora async overloaded command dispatcher thread worker id
*/
AUKN_SYM bool DispatchCommand(const AuString &string);
AUKN_SYM bool DispatchCommand(const AuROString &string);
/**
* Parses `string` and dispatches the parsed command on the current thread instantly
*/
AUKN_SYM bool DispatchCommandThisThread(const AuString &string);
AUKN_SYM bool DispatchCommandThisThread(const AuROString &string);
/**
* Parses `string` on the current thread and then schedules the ICommandSubscriber callback on the specified thread
*/
AUKN_SYM bool DispatchCommandToAsyncRunner(const AuString &string, Async::WorkerPId_t id);
AUKN_SYM bool DispatchCommandToAsyncRunner(const AuROString &string, Async::WorkerPId_t id);
}

View File

@ -15,9 +15,9 @@ namespace Aurora::Crypto::PEM
AUKN_SYM AuString PublicRSAToString(const DerBuffer &in);
AUKN_SYM AuString PrivateRSAToString(const DerBuffer &in);
AUKN_SYM bool FromString(const AuString &in, Aurora::Crypto::X509::Certificate &out);
AUKN_SYM bool PublicFromString(const AuString &in, DerBuffer &out);
AUKN_SYM bool PrivateFromString(const AuString &in, DerBuffer &out);
AUKN_SYM bool PublicRSAFromString(const AuString &in, DerBuffer &out);
AUKN_SYM bool PrivateRSAFromString(const AuString &in, DerBuffer &out);
AUKN_SYM bool FromString(const AuROString &in, Aurora::Crypto::X509::Certificate &out);
AUKN_SYM bool PublicFromString(const AuROString &in, DerBuffer &out);
AUKN_SYM bool PrivateFromString(const AuROString &in, DerBuffer &out);
AUKN_SYM bool PublicRSAFromString(const AuROString &in, DerBuffer &out);
AUKN_SYM bool PrivateRSAFromString(const AuROString &in, DerBuffer &out);
}

View File

@ -12,5 +12,5 @@ namespace Aurora::IO::Character
// you are responsible for maintaining a lock over shared string writes and provider use instances
// (string may change so long as a read/write lock is protecting ICharacterProviderEx reads)
AUKN_SHARED_API(ProviderFromSharedString, ICharacterProviderEx, const AuSPtr<AuString> &str, AuUInt index = 0);
AUKN_SHARED_API(ProviderFromString, ICharacterProviderEx, const AuString &str, AuUInt index = 0);
AUKN_SHARED_API(ProviderFromString, ICharacterProviderEx, const AuROString &str, AuUInt index = 0);
}

View File

@ -10,7 +10,7 @@
namespace Aurora::IO::FS
{
AUKN_SHARED_API(OpenAsync, IAsyncFileStream,
const AuString &path,
const AuROString &path,
EFileOpenMode openMode,
AuOptional<bool> optbDirectIO = { true },
AuOptional<EFileAdvisoryLockLevel> optLock = { EFileAdvisoryLockLevel::eNoSafety });

View File

@ -17,34 +17,34 @@ namespace Aurora::IO::FS
Lists files with respect to a given partial or full path of a directory
@param files relative address of an entry
*/
AUKN_SYM bool FilesInDirectory(const AuString &string, AuList<AuString> &files);
AUKN_SYM bool FilesInDirectory(const AuROString &string, AuList<AuString> &files);
/**
Lists directories with respect to a given partial or full path of a directory
@param files relative address of an entry
*/
AUKN_SYM bool DirsInDirectory(const AuString &string, AuList<AuString> &dirs);
AUKN_SYM bool DirsInDirectory(const AuROString &string, AuList<AuString> &dirs);
/**
@brief Opens a directory iterator given a directory path
* @param directory An Aurora path as defined in the README
* @return
*/
AUKN_SYM AuSPtr<IReadDir> ReadDir(const AuString &directory);
AUKN_SYM AuSPtr<IReadDir> ReadDir(const AuROString &directory);
/**
* @brief
* @param string
* @return
*/
AUKN_SYM AuSPtr<IReadDir> ReadDirRecursive(const AuString &string, AuOptional<bool> bTraverseSymlinks = { true });
AUKN_SYM AuSPtr<IReadDir> ReadDirRecursive(const AuROString &string, AuOptional<bool> bTraverseSymlinks = { true });
/**
* @brief Recursively deletes any given path
* @param string
* @return
*/
AUKN_SYM bool DirDeleter(const AuString &string);
AUKN_SYM bool DirDeleter(const AuROString &string);
/**
* @brief
@ -52,7 +52,7 @@ namespace Aurora::IO::FS
* @param failingPaths
* @return
*/
AUKN_SYM bool DirDeleterEx(const AuString &string, AuList<AuString> &failingPaths);
AUKN_SYM bool DirDeleterEx(const AuROString &string, AuList<AuString> &failingPaths);
struct CopyDirResult
{
@ -76,7 +76,7 @@ namespace Aurora::IO::FS
* @param blob
* @return true on success
*/
AUKN_SYM bool WriteFile(const AuString &path, const Memory::MemoryViewRead &blob);
AUKN_SYM bool WriteFile(const AuROString &path, const Memory::MemoryViewRead &blob);
/**
* @brief Same as WriteFile except fails if the file already exists
@ -88,7 +88,7 @@ namespace Aurora::IO::FS
* @param blob
* @return
*/
AUKN_SYM bool WriteNewFile(const AuString &path, const Memory::MemoryViewRead &blob);
AUKN_SYM bool WriteNewFile(const AuROString &path, const Memory::MemoryViewRead &blob);
/**
* @brief Writes a UTF-8 string onto disk with a BOM
@ -97,7 +97,7 @@ namespace Aurora::IO::FS
* @param str UTF-8 bytecode (can be ASCII)
* @return true on success
*/
AUKN_SYM bool WriteString(const AuString &path, const AuString &str);
AUKN_SYM bool WriteString(const AuROString &path, const AuROString &str);
/**
* @brief Same as WriteString except fails if the file already exists
@ -109,7 +109,7 @@ namespace Aurora::IO::FS
* @param str
* @return
*/
AUKN_SYM bool WriteNewString(const AuString &path, const AuString &str);
AUKN_SYM bool WriteNewString(const AuROString &path, const AuROString &str);
/**
* @brief Returns a bytebuffer (does not write into) of a binary files contents
@ -117,7 +117,7 @@ namespace Aurora::IO::FS
* @param buffer
* @return
*/
AUKN_SYM bool ReadFile(const AuString &path, Memory::ByteBuffer &buffer);
AUKN_SYM bool ReadFile(const AuROString &path, Memory::ByteBuffer &buffer);
/**
* @brief Reads a UTF-8 string from the disk.
@ -130,9 +130,9 @@ namespace Aurora::IO::FS
* @param buffer
* @return true on success
*/
AUKN_SYM bool ReadString(const AuString &path, AuString &buffer);
AUKN_SYM bool ReadString(const AuROString &path, AuString &buffer);
AUKN_SYM bool ReadFileHeader(const AuString &path, AuUInt16 uLength, Memory::ByteBuffer &buffer);
AUKN_SYM bool ReadFileHeader(const AuROString &path, AuUInt16 uLength, Memory::ByteBuffer &buffer);
/**
* @brief Returns a non-atomic non-promise that the requested file didn't exist.
@ -140,20 +140,20 @@ namespace Aurora::IO::FS
* Do not solely rely on this return value.
* @param path An Aurora path as defined in the README
*/
AUKN_SYM bool FileExists(const AuString &path);
AUKN_SYM bool FileExists(const AuROString &path);
/**
* @brief Returns a non-atomic non-promise that the requested directory didn't exist.
* @param path An Aurora path as defined in the README
*/
AUKN_SYM bool DirExists(const AuString &path);
AUKN_SYM bool DirExists(const AuROString &path);
/**
* @brief
* @param path
* @return
*/
AUKN_SYM bool DirMk(const AuString &path);
AUKN_SYM bool DirMk(const AuROString &path);
/**
* @brief Deletes a file or an empty directory
@ -162,7 +162,7 @@ namespace Aurora::IO::FS
* @warning Directory iteration is not supported. No FS API will do
* iterative tasks for you.
*/
AUKN_SYM bool Remove(const AuString &path);
AUKN_SYM bool Remove(const AuROString &path);
/**
* @brief Attempts to move a directory or file from the source
@ -172,7 +172,7 @@ namespace Aurora::IO::FS
* @param dest The source Aurora path as defined in the README
* @return true on success
*/
AUKN_SYM bool Relink(const AuString &src, const AuString &dest);
AUKN_SYM bool Relink(const AuROString &src, const AuROString &dest);
/**
* @brief Performs a synchronous platform-optimized copy of
@ -184,21 +184,21 @@ namespace Aurora::IO::FS
* iterative tasks for you.
* @return true on success
*/
AUKN_SYM bool Copy(const AuString &src, const AuString &dest);
AUKN_SYM bool Copy(const AuROString &src, const AuROString &dest);
/**
* @brief Specifies download level of trust
* @param path
* @return
*/
AUKN_SYM bool BlockFile(const AuString &path);
AUKN_SYM bool BlockFile(const AuROString &path);
/**
* @brief Specifies generic local-system/trusted level of trust
* @param path
* @return
*/
AUKN_SYM bool UnblockFile(const AuString &path);
AUKN_SYM bool UnblockFile(const AuROString &path);
/**
* @brief Specifies user/executable level trust of a file
@ -210,11 +210,11 @@ namespace Aurora::IO::FS
* @param path
* @return
*/
AUKN_SYM bool TrustFile(const AuString &path);
AUKN_SYM bool TrustFile(const AuROString &path);
AUKN_SYM bool IsFileBlocked(const AuString &path);
AUKN_SYM bool IsFileBlocked(const AuROString &path);
AUKN_SYM bool IsFileTrusted(const AuString &path);
AUKN_SYM bool IsFileTrusted(const AuROString &path);
/**
* @brief Transfers the contents of the specified filepath through a
@ -222,13 +222,13 @@ namespace Aurora::IO::FS
* @warning This file API does not relate to file-system level compression
* @param path = ur mother
*/
AUKN_SYM bool Compress(const AuString &path, AuInt8 level = 17);
AUKN_SYM bool Compress(const AuROString &path, AuInt8 level = 17);
AUKN_SYM bool CompressEx(const AuString &path, const AuString &suffix, Compression::ECompressionType type, AuInt8 level);
AUKN_SYM bool CompressEx(const AuROString &path, const AuROString &suffix, Compression::ECompressionType type, AuInt8 level);
AUKN_SYM bool Decompress(const AuString &path);
AUKN_SYM bool Decompress(const AuROString &path);
AUKN_SYM bool DecompressEx(const AuString &path, const AuString &suffix, Compression::ECompressionType type);
AUKN_SYM bool DecompressEx(const AuROString &path, const AuROString &suffix, Compression::ECompressionType type);
struct UpdateTimes
{
@ -242,14 +242,14 @@ namespace Aurora::IO::FS
* @param times
* @return
*/
AUKN_SYM bool UpdateFileTimes(const AuString &path, const UpdateTimes &times);
AUKN_SYM bool UpdateFileTimes(const AuROString &path, const UpdateTimes &times);
/**
* @brief
* @param path
* @return
*/
AUKN_SYM AuList<AuString> FileAttrsList(const AuString &path);
AUKN_SYM AuList<AuString> FileAttrsList(const AuROString &path);
/**
* @brief
@ -257,7 +257,7 @@ namespace Aurora::IO::FS
* @param attr
* @return
*/
AUKN_SYM AuResult<Memory::ByteBuffer> FileAttrsGet(const AuString &path, const AuString &attr);
AUKN_SYM AuResult<Memory::ByteBuffer> FileAttrsGet(const AuROString &path, const AuROString &attr);
/**
* @brief
@ -266,7 +266,7 @@ namespace Aurora::IO::FS
* @param view
* @return
*/
AUKN_SYM bool FileAttrsSet(const AuString &path, const AuString &attr, const Memory::MemoryViewRead &view);
AUKN_SYM bool FileAttrsSet(const AuROString &path, const AuROString &attr, const Memory::MemoryViewRead &view);
/**
* @brief
@ -274,7 +274,7 @@ namespace Aurora::IO::FS
* @param attr
* @return
*/
AUKN_SYM bool FileAttrsDel(const AuString &path, const AuString &attr);
AUKN_SYM bool FileAttrsDel(const AuROString &path, const AuROString &attr);
/**
* @brief Normalizes an arbitrary string of in
@ -282,7 +282,7 @@ namespace Aurora::IO::FS
* @param in
* @return
*/
AUKN_SYM bool NormalizePath(AuString &out, const AuString &in);
AUKN_SYM bool NormalizePath(AuString &out, const AuROString &in);
/**
* @brief Strips the filename part out of an Aurora path
@ -290,7 +290,7 @@ namespace Aurora::IO::FS
* @param path
* @return
*/
AUKN_SYM bool GetFileFromPath(AuString &out, const AuString &path);
AUKN_SYM bool GetFileFromPath(AuROString &out, const AuROString &path);
/**
* @brief Strips the directory part out of an Aurora path
@ -298,9 +298,9 @@ namespace Aurora::IO::FS
* @param path
* @return
*/
AUKN_SYM bool GetDirectoryFromPath(AuString &out, const AuString &path);
AUKN_SYM bool GetDirectoryFromPath(AuROString &out, const AuROString &path);
AUKN_SYM bool GoUpToSeparator(AuString &out, const AuString &path);
AUKN_SYM bool GoUpToSeparator(AuROString &out, const AuROString &path);
// Further apis can be found in: Stat.hpp, FileStream.hpp, Async.hpp, and Resources.hpp
}

View File

@ -11,13 +11,13 @@ namespace Aurora::IO::FS
{
// WARNING: there are no truncate write modes. IFileStream::WriteEoS or IFileStream::SetWriteEoSOnClose must be called by the caller of `Open[Write]/Create`s.
AUKN_SHARED_API(Create, IFileStream, const AuString &path);
AUKN_SHARED_API(Create, IFileStream, const AuROString &path);
AUKN_SHARED_API(OpenRead, IFileStream, const AuString &path, EFileAdvisoryLockLevel successPostAdvisoryLevel = EFileAdvisoryLockLevel::eBlockWrite);
AUKN_SHARED_API(OpenRead, IFileStream, const AuROString &path, EFileAdvisoryLockLevel successPostAdvisoryLevel = EFileAdvisoryLockLevel::eBlockWrite);
AUKN_SHARED_API(OpenWrite, IFileStream, const AuString &path, EFileAdvisoryLockLevel successPostAdvisoryLevel = EFileAdvisoryLockLevel::eBlockReadWrite);
AUKN_SHARED_API(OpenWrite, IFileStream, const AuROString &path, EFileAdvisoryLockLevel successPostAdvisoryLevel = EFileAdvisoryLockLevel::eBlockReadWrite);
AUKN_SHARED_API(Open, IFileStream, const AuString &path, EFileOpenMode mode = EFileOpenMode::eRead, EFileAdvisoryLockLevel successPostAdvisoryLevel = EFileAdvisoryLockLevel::eBlockReadWrite);
AUKN_SHARED_API(Open, IFileStream, const AuROString &path, EFileOpenMode mode = EFileOpenMode::eRead, EFileAdvisoryLockLevel successPostAdvisoryLevel = EFileAdvisoryLockLevel::eBlockReadWrite);
AUKN_SHARED_API(OpenBlockingFileStreamFromHandle, IFileStream, const AuSPtr<IIOHandle> &pIOHandle);
}

View File

@ -35,5 +35,5 @@ namespace Aurora::IO::FS
/**
Classic file stat function
*/
AUKN_SYM bool StatFile(const AuString &path, Stat &stat);
AUKN_SYM bool StatFile(const AuROString &path, Stat &stat);
}

View File

@ -37,7 +37,7 @@ namespace Aurora::IO
/**
* Path
*/
const AuString &path;
AuROString path;
/**
* Mode
@ -70,7 +70,7 @@ namespace Aurora::IO
*/
bool bWriteEoSOnClose { false };
cstatic HandleCreate Create(const AuString &path)
cstatic HandleCreate Create(const AuROString &path)
{
HandleCreate create(path);
create.bFailIfNonEmptyFile = true;
@ -79,7 +79,7 @@ namespace Aurora::IO
return AuMove(create);
}
cstatic HandleCreate ReadWrite(const AuString &path)
cstatic HandleCreate ReadWrite(const AuROString &path)
{
HandleCreate create(path);
create.eMode = FS::EFileOpenMode::eReadWrite;
@ -87,7 +87,7 @@ namespace Aurora::IO
return AuMove(create);
}
cstatic HandleCreate Read(const AuString &path)
cstatic HandleCreate Read(const AuROString &path)
{
HandleCreate read(path);
read.eMode = FS::EFileOpenMode::eRead;
@ -95,7 +95,7 @@ namespace Aurora::IO
return AuMove(read);
}
cstatic HandleCreate Open(const AuString &path)
cstatic HandleCreate Open(const AuROString &path)
{
HandleCreate read(path);
read.eMode = FS::EFileOpenMode::eRead;
@ -103,7 +103,7 @@ namespace Aurora::IO
return AuMove(read);
}
inline HandleCreate(const AuString &path) :
inline HandleCreate(const AuROString &path) :
path(path),
eAdvisoryLevel(FS::EFileAdvisoryLockLevel::eNoSafety),
eMode(FS::EFileOpenMode::eRead)

View File

@ -34,7 +34,7 @@ namespace Aurora::Locale
AUKN_SYM LocalizationInfo GetLocale();
#if defined(AURORA_PLATFORM_WIN32) || defined(I_REALLY_NEED_WIDECHAR_PUBAPI)
AUKN_SYM std::wstring ConvertFromUTF8(const AuString &in);
AUKN_SYM std::wstring ConvertFromUTF8(const AuROString &in);
AUKN_SYM AuString ConvertFromWChar(const wchar_t *in, AuMach length);
AUKN_SYM AuString ConvertFromWChar(const wchar_t *in);
#endif

View File

@ -544,7 +544,7 @@ namespace Aurora::Memory
// String API
inline bool WriteString(std::string_view string, EStringType type = EStringType::eStringDword, Locale::ECodePage codepage = Locale::ECodePage::eUTF8);
inline bool WriteString(AuROString string, EStringType type = EStringType::eStringDword, Locale::ECodePage codepage = Locale::ECodePage::eUTF8);
inline bool ReadString(AuString &string, EStringType type = EStringType::eStringDword, Locale::ECodePage codepage = Locale::ECodePage::eUTF8);
// Copy, concat, etc

View File

@ -14,7 +14,7 @@
namespace Aurora::Memory
{
bool ByteBuffer::WriteString(std::string_view string, EStringType type, Locale::ECodePage codepage)
bool ByteBuffer::WriteString(AuROString string, EStringType type, Locale::ECodePage codepage)
{
ByteBufferPushWriteState a(*this);
AuStreamReadWrittenPair_t len {};

View File

@ -129,7 +129,7 @@ namespace Aurora::Memory
return (AuUInt8)Data::EDataType::kTypeSpecialObject;
}
else if constexpr (AuIsSame_v<AuRemoveReference_t<T>, AuString> ||
AuIsSame_v<AuRemoveReference_t<T>, std::string_view>)
AuIsSame_v<AuRemoveReference_t<T>, AuROString>)
{
return (AuUInt8)Data::EDataType::kTypeString;
}
@ -432,7 +432,7 @@ namespace Aurora::Memory
Write(in.data(), in.size());
return !this->flagWriteError;
}
else if constexpr (AuIsSame_v<AuRemoveReference_t<T>, std::string_view>)
else if constexpr (AuIsSame_v<AuRemoveReference_t<T>, AuROString>)
{
Write<AuUInt32>(AuUInt32(in.size()));
Write(in.data(), in.size());

View File

@ -61,6 +61,12 @@ namespace Aurora::Memory
this->length = list.size() * sizeof(typename T::value_type);
}
MemoryView(const AuROString &str)
{
this->ptr = str.data();
this->length = str.size();
}
MemoryView(const AuString &str)
{
this->ptr = str.data();

View File

@ -9,7 +9,7 @@
namespace Aurora::Parse
{
AUKN_SYM bool Base32Decode(const AuString &in, Memory::ByteBuffer &decoded);
AUKN_SYM bool Base32Decode(const AuROString &in, Memory::ByteBuffer &decoded);
AUKN_SYM bool Base32Encode(const Memory::MemoryViewRead &input, AuString &encoded);
}

View File

@ -9,7 +9,7 @@
namespace Aurora::Parse
{
AUKN_SYM bool Base64Decode(const AuString &in, Memory::ByteBuffer &decoded, bool url = false);
AUKN_SYM bool Base64Decode(const AuROString &in, Memory::ByteBuffer &decoded, bool url = false);
AUKN_SYM bool Base64Encode(const Memory::MemoryViewRead &input, AuString &encoded, bool url = false);

View File

@ -18,9 +18,10 @@ namespace Aurora::Parse
eJSLiteral
));
AUKN_SYM bool HexToByte(const char(hex)[2], AuUInt8 &val);
AUKN_SYM void ByteToHex(AuUInt8 val, char(&hex)[2]);
AUKN_SYM bool HexToInt (const char *hex, AuUInt32 length, AuUInt64 &val);
AUKN_SYM bool HexToInt (const AuROString &hex, AuUInt64 &val);
AUKN_SYM bool EncodeHex(Memory::MemoryViewRead view, EHexDump formatting, AuString &out);
AUKN_SYM bool DecodeHex(const AuString &in, Memory::ByteBuffer &out);
AUKN_SYM bool DecodeHex(const AuROString &in, Memory::ByteBuffer &out);
}

View File

@ -9,7 +9,7 @@
namespace Aurora::Parse
{
static AuString SplitNewlines(const AuString &in, AuFunction<void(const AuString &)> lineCallback, bool returnRemaining)
static AuROString SplitNewlines(const AuROString &in, AuFunction<void(const AuROString &)> lineCallback, bool returnRemaining)
{
AuMach index = 0, startIdx = 0;
@ -20,7 +20,7 @@ namespace Aurora::Parse
if (line[line.size() - 1] == '\r')
{
line.pop_back();
line.remove_suffix(1);
}
lineCallback(line);
@ -42,14 +42,14 @@ namespace Aurora::Parse
}
}
static void SplitNewlines(const AuString &in, AuFunction<void(const AuString &)> lineCallback)
static void SplitNewlines(const AuROString &in, AuFunction<void(const AuROString &)> lineCallback)
{
SplitNewlines(in, lineCallback, false);
}
static AuList<AuString> SplitString(const AuString &in, AuUInt16 characters)
static AuList<AuROString> SplitString(const AuROString &in, AuUInt16 characters)
{
AuList<AuString> ret;
AuList<AuROString> ret;
for (auto i = 0u; i < in.size(); i += characters)
{
auto start = i;
@ -60,7 +60,7 @@ namespace Aurora::Parse
return ret;
}
static AuString SplitStringDelm(const AuString &in, const AuString &delm, AuUInt16 characters)
static AuString SplitStringDelm(const AuROString &in, const AuString &delm, AuUInt16 characters)
{
AuString ret;
ret.reserve(in.size());

View File

@ -147,7 +147,7 @@ namespace Aurora::Parse
AUKN_SYM bool ConsumeToken(ParseState &state, ParsableTag type, ParseValue &out);
static bool ConsumeToken(ParsableTag type, const AuString &str, AuMach &index, ParseValueEx &out)
static bool ConsumeToken(ParsableTag type, const AuROString &str, AuMach &index, ParseValueEx &out)
{
auto base = IO::Character::ProviderFromStringUnique(str, index);
if (!base) return false;
@ -158,7 +158,7 @@ namespace Aurora::Parse
return true;
}
static bool ConsumeToken(ParsableTag type, const AuString &str, ParseValueEx &out)
static bool ConsumeToken(ParsableTag type, const AuROString &str, ParseValueEx &out)
{
auto base = IO::Character::ProviderFromStringUnique(str);
if (!base) return false;
@ -169,7 +169,7 @@ namespace Aurora::Parse
AUKN_SYM bool Parse(ParseState &state, const ParseObject &structure, ParseResult &result);
static bool Parse(ParseResult &result, const ParseObject &structure, const AuString &str, AuMach &index)
static bool Parse(ParseResult &result, const ParseObject &structure, const AuROString &str, AuMach &index)
{
auto base = IO::Character::ProviderFromStringUnique(str);
if (!base) return false;
@ -181,7 +181,7 @@ namespace Aurora::Parse
return true;
}
static bool Parse(ParseResult &result, const ParseObject &structure, const AuString &str)
static bool Parse(ParseResult &result, const ParseObject &structure, const AuROString &str)
{
auto base = IO::Character::ProviderFromStringUnique(str);
if (!base) return false;
@ -230,7 +230,7 @@ namespace Aurora::Parse
/**
* @brief Parse base16 abi terminated string with optional 0x suffix and 'h' ending
*/
AUKN_SYM AuResult<AuSInt> ParseSInt16(const AuString &str);
AUKN_SYM AuResult<AuSInt> ParseSInt16(const AuROString &str);
/**
* @brief Parse base16 null terminated string with optional 0x suffix and 'h' ending
@ -240,13 +240,13 @@ namespace Aurora::Parse
/**
* @brief Parse base16 abi terminated string with optional 0x suffix and 'h' ending
*/
AUKN_SYM AuResult<AuUInt> ParseUInt16(const AuString &str);
AUKN_SYM AuResult<AuUInt> ParseUInt16(const AuROString &str);
/**
* @brief Parse abi null terminated string
*/
AUKN_SYM AuResult<AuSInt> ParseSInt(const AuString &str);
AUKN_SYM AuResult<AuSInt> ParseSInt(const AuROString &str);
/**
* @brief Parse base10 null terminated string
@ -256,7 +256,7 @@ namespace Aurora::Parse
/**
* @brief Parse base10 abi terminated string
*/
AUKN_SYM AuResult<AuUInt> ParseUInt(const AuString &str);
AUKN_SYM AuResult<AuUInt> ParseUInt(const AuROString &str);
/**
* @brief Parse base10 null terminated string

View File

@ -14,13 +14,12 @@ namespace Aurora::Processes
* @param uri
* @return
*/
AUKN_SYM void OpenUri(const AuString &uri);
AUKN_SYM void OpenUri(const AuROString &uri);
/**
* @brief Opens a file or directory
* @param file unexpanded relative or absolute filepath
* @return
*/
AUKN_SYM void OpenFile(const AuString &file);
AUKN_SYM void OpenFile(const AuROString &file);
}

View File

@ -24,18 +24,18 @@ namespace Aurora::CmdLine
return gCmdLineString;
}
AUKN_SYM bool HasFlag(const AuString &key)
AUKN_SYM bool HasFlag(const AuROString &key)
{
return gCmdFlagLookup.find(key) != gCmdFlagLookup.end();
return AuExists(gCmdFlagLookup, key);
}
AUKN_SYM bool HasValue(const AuString &key)
AUKN_SYM bool HasValue(const AuROString &key)
{
return gCmdValueArrayMap.find(key) != gCmdValueArrayMap.end() ||
gCmdValueMap.find(key) != gCmdValueMap.end();
return AuExists(gCmdValueArrayMap, key) ||
AuExists(gCmdValueMap, key);
}
AUKN_SYM const AuString &GetValue(const AuString &key, const AuString &defaultValue)
AUKN_SYM const AuString &GetValue(const AuROString &key, const AuString &defaultValue)
{
auto itr = gCmdValueMap.find(key);
if (itr == gCmdValueMap.end())
@ -48,7 +48,7 @@ namespace Aurora::CmdLine
}
}
AUKN_SYM AuOptional<const AuString &> GetValue(const AuString &key)
AUKN_SYM AuOptional<const AuString &> GetValue(const AuROString &key)
{
auto itr = gCmdValueMap.find(key);
if (itr == gCmdValueMap.end())
@ -58,10 +58,11 @@ namespace Aurora::CmdLine
return itr->second;
}
AUKN_SYM const AuList<AuString> &GetValues(const AuString &key)
AUKN_SYM const AuList<AuString> &GetValues(const AuROString &key)
{
static AuList<AuString> kMissing;
auto itr = gCmdValueArrayMap.find(key);
AuString temp(key);
auto itr = gCmdValueArrayMap.find(temp);
if (itr != gCmdValueArrayMap.end())
{
return itr->second;

View File

@ -44,11 +44,13 @@ namespace Aurora::Console::Commands
eAsync
};
static bool Dispatch(const AuString &string, EDispatchType type, AuOptionalEx<AuWorkerPId_t> workerId)
static bool Dispatch(const AuROString &string, EDispatchType type, AuOptionalEx<AuWorkerPId_t> workerId)
{
Parse::ParseResult res;
AuSPtr<ICommandSubscriber> callback;
// TODO: try catch?
{
AU_LOCK_GUARD(gPendingCommandsMutex);
@ -113,30 +115,30 @@ namespace Aurora::Console::Commands
return true;
}
AUKN_SYM void RemoveCommand(const AuString &tag)
AUKN_SYM void RemoveCommand(const AuROString &tag)
{
AU_LOCK_GUARD(gPendingCommandsMutex);
AuTryRemove(gCommands, tag);
}
AUKN_SYM void AddCommand(const AuString &tag, const Parse::ParseObject &commandStructure, const AuSPtr<ICommandSubscriber> &callback)
AUKN_SYM void AddCommand(const AuROString &tag, const Parse::ParseObject &commandStructure, const AuSPtr<ICommandSubscriber> &callback)
{
AU_LOCK_GUARD(gPendingCommandsMutex);
SysAssert(callback);
gCommands.insert(AuMakePair(tag, Command(tag, commandStructure, callback)));
gCommands.insert(AuMakePair(AuString(tag), Command(AuString(tag), commandStructure, callback)));
}
AUKN_SYM bool DispatchCommand(const AuString &string)
AUKN_SYM bool DispatchCommand(const AuROString &string)
{
return Dispatch(string, EDispatchType::eSys, gCommandDispatcher);
}
AUKN_SYM bool DispatchCommandThisThread(const AuString &string)
AUKN_SYM bool DispatchCommandThisThread(const AuROString &string)
{
return Dispatch(string, EDispatchType::eNow, {});
}
AUKN_SYM bool DispatchCommandToAsyncRunner(const AuString &string, Async::WorkerPId_t id)
AUKN_SYM bool DispatchCommandToAsyncRunner(const AuROString &string, Async::WorkerPId_t id)
{
return Dispatch(string, EDispatchType::eAsync, id);
}

View File

@ -248,7 +248,7 @@ namespace Aurora::Console::ConsoleStd
}
{
auto remaining = AuParse::SplitNewlines(str, [](const AuString &line)
auto remaining = AuParse::SplitNewlines(str, [](const AuROString &line)
{
NoncanonicalInput canInput {};
canInput.type = ENoncanonicalInput::eInput;

View File

@ -964,9 +964,9 @@ namespace Aurora::Console::ConsoleTTY
return;
}
AuParse::SplitNewlines(buffer, [&](const AuString &in)
AuParse::SplitNewlines(buffer, [&](const AuROString &in)
{
this->history.push_back(in);
this->history.push_back(AuString(in));
});
this->iHistoryWritePos = this->history.size();

View File

@ -88,7 +88,7 @@ namespace Aurora::Console::Hooks
else [[unlikely]]
{
Parse::SplitNewlines(msg.line,
[&](const AuString &line)
[&](const AuROString &line)
{
ConsoleMessage dup = msg;
dup.line = line;

View File

@ -11,7 +11,7 @@
namespace Aurora::Crypto::PEM
{
static bool ParsePEM(const AuString &begin, const AuString &end, const AuString &src, AuByteBuffer &buf)
static bool ParsePEM(const AuROString &begin, const AuROString &end, const AuROString &src, AuByteBuffer &buf)
{
AuUInt lines = 0;
AuString str;
@ -23,7 +23,7 @@ namespace Aurora::Crypto::PEM
str.reserve(src.size());
Parse::SplitNewlines(src,
[&](const AuString &src)
[&](const AuROString &src)
{
if (lines == 0)
{
@ -50,7 +50,7 @@ namespace Aurora::Crypto::PEM
return fail ? false : finished;
}
static AuString SerializePEM(const AuString &begin, const AuString &end, const AuByteBuffer &buf)
static AuString SerializePEM(const AuROString &begin, const AuROString &end, const AuByteBuffer &buf)
{
auto &delm = AuLocale::NewLine();
AuString ret;
@ -104,27 +104,27 @@ namespace Aurora::Crypto::PEM
return SerializePEM("-----BEGIN RSA PRIVATE KEY-----", "-----END RSA PRIVATE KEY-----", in);
}
AUKN_SYM bool FromString(const AuString &in, Aurora::Crypto::X509::Certificate &out)
AUKN_SYM bool FromString(const AuROString &in, Aurora::Crypto::X509::Certificate &out)
{
return ParsePEM("-----BEGIN CERTIFICATE-----", "-----END CERTIFICATE-----", in, out);
}
AUKN_SYM bool PrivateFromString(const AuString &in, DerBuffer &out)
AUKN_SYM bool PrivateFromString(const AuROString &in, DerBuffer &out)
{
return ParsePEM("-----BEGIN PRIVATE KEY-----", "-----END PRIVATE KEY-----", in, out);
}
AUKN_SYM bool PublicRSAFromString(const AuString &in, DerBuffer &out)
AUKN_SYM bool PublicRSAFromString(const AuROString &in, DerBuffer &out)
{
return ParsePEM("-----BEGIN RSA PUBLIC KEY-----", "-----END RSA PUBLIC KEY-----", in, out);
}
AUKN_SYM bool PrivateRSAFromString(const AuString &in, DerBuffer &out)
AUKN_SYM bool PrivateRSAFromString(const AuROString &in, DerBuffer &out)
{
return ParsePEM("-----BEGIN RSA PRIVATE KEY-----", "-----END RSA PRIVATE KEY-----", in, out);
}
AUKN_SYM bool PublicFromString(const AuString &in, DerBuffer &out)
AUKN_SYM bool PublicFromString(const AuROString &in, DerBuffer &out)
{
return ParsePEM("-----BEGIN PUBLIC KEY-----", "-----END PUBLIC KEY-----", in, out);
}

View File

@ -407,7 +407,7 @@ namespace Aurora::Debug
if (frame.label)
{
auto parts = AuSplitString(frame.label.value(), "+");
if (auto resultName = DemangleName(parts[0]))
if (auto resultName = DemangleName(AuString(parts[0])))
{
if (resultName.value() == parts[0])
{

View File

@ -147,7 +147,7 @@ namespace Aurora::HWInfo
return false;
}
AuParse::SplitNewlines(statFile, [&](const AuString &line)
AuParse::SplitNewlines(statFile, [&](const AuROString &line)
{
CpuCoreTime coreTimes;

View File

@ -10,6 +10,12 @@
namespace Aurora::IO::Character
{
BufferedLineReader::BufferedLineReader(AuSPtr<IStreamReader> reader) :
pInputStream_(reader)
{
}
void BufferedLineReader::Flush()
{
this->flushLine_ = true;
@ -26,7 +32,7 @@ namespace Aurora::IO::Character
}
AuUInt bytesRead;
if (this->inputStream_->Read(AuMemoryViewStreamWrite(AuMemoryViewWrite(this->buffer_.writePtr, this->buffer_.writePtr + this->buffer_.length), bytesRead)) !=
if (this->pInputStream_->Read(AuMemoryViewStreamWrite(AuMemoryViewWrite(this->buffer_.writePtr, this->buffer_.writePtr + this->buffer_.length), bytesRead)) !=
EStreamError::eErrorNone)
{
SysPushErrorIO();
@ -53,31 +59,37 @@ namespace Aurora::IO::Character
{
Memory::ByteBufferPushReadState _(this->buffer_, true);
if (*this->buffer_.readPtr != '\n')
auto pStartPointer = this->buffer_.readPtr;
if (*this->buffer_.readPtr != '\n' &&
this->buffer_.readPtr < this->buffer_.base + this->buffer_.length)
{
this->buffer_.readPtr++;
continue;
}
auto end = this->buffer_.GetReadOffset();
auto next = end + 1;
if (end != 0)
auto pEndReadPointer = this->buffer_.readPtr;
auto pEndReadPointer2 = this->buffer_.readPtr;
if (pEndReadPointer != this->buffer_.base)
{
if (this->buffer_.readPtr[-1] == '\r')
if (pEndReadPointer[-1] == '\r')
{
end--;
pEndReadPointer--;
}
}
try
{
if (!AuTryInsert(ret, AuString(this->buffer_.base, this->buffer_.base + end)))
AuMemoryViewRead view = this->buffer_;
if (AuTryInsert(ret, AuString((char *)pStartPointer, (char *)pEndReadPointer)))
{
this->buffer_.flagReadError = true;
break;
}
this->buffer_.readPtr = this->buffer_.base + next;
this->buffer_.readPtr = pEndReadPointer2;
}
catch (...)
{
@ -91,9 +103,10 @@ namespace Aurora::IO::Character
{
try
{
if (AuTryInsert(ret, AuString(this->buffer_.base, this->buffer_.base + this->buffer_.length)))
AuMemoryViewRead view = this->buffer_;
if (AuTryInsert(ret, AuString(view.begin(), view.end())))
{
this->buffer_.readPtr = this->buffer_.base + this->buffer_.length;
this->buffer_.readPtr += view.length;
}
}
catch (...)
@ -102,12 +115,18 @@ namespace Aurora::IO::Character
}
}
if (this->buffer_.readPtr == this->buffer_.writePtr)
{
this->buffer_.readPtr = this->buffer_.writePtr = this->buffer_.base;
}
return ret;
}
AUKN_SYM IBufferedLineReader *NewLineReaderNew(const AuSPtr<IStreamReader> &input)
AUKN_SYM IBufferedLineReader *NewLineReaderNew(const AuSPtr<IStreamReader> &pInputReader)
{
return _new BufferedLineReader(input);
SysCheckArgNotNull(pInputReader, {});
return _new BufferedLineReader(pInputReader);
}
AUKN_SYM void NewLineReaderNew(IBufferedLineReader *reader)

View File

@ -9,10 +9,9 @@
namespace Aurora::IO::Character
{
struct BufferedLineReader : public IBufferedLineReader
struct BufferedLineReader : IBufferedLineReader
{
BufferedLineReader(AuSPtr<IStreamReader> reader) : inputStream_(reader)
{};
BufferedLineReader(AuSPtr<IStreamReader> reader);
virtual bool ReadBytes(AuUInt32 length) override;
virtual AuList<AuString> ReadLines() override;
@ -20,9 +19,9 @@ namespace Aurora::IO::Character
private:
AuSPtr<IStreamReader> inputStream_;
AuSPtr<IStreamReader> pInputStream_;
AuByteBuffer buffer_;
bool flushLine_;
AuThreadPrimitives::SpinLock lock_;
bool flushLine_ {};
AuMutex lock_;
};
}

View File

@ -10,62 +10,64 @@
namespace Aurora::IO::Character
{
class CharacterProvider : public ICharacterProviderEx
struct CharacterProvider : ICharacterProviderEx
{
public:
CharacterProvider(const AuString &in, AuUInt offset = 0);
CharacterProvider(const AuROString &in, AuUInt offset = 0);
CharacterProvider(const AuSPtr<AuString> &in, AuUInt offset = 0);
bool GetByte(AuUInt8 &val) override;
AuUInt GetPosition() override;
bool SetPosition(AuUInt offset) override;
bool HasString();
protected:
AuUInt offset_ {};
AuSPtr<AuString> string_;
AuUInt uOffset_ {};
AuSPtr<AuString> pString_;
};
CharacterProvider::CharacterProvider(const AuString &in, AuUInt offset) : string_(AuMakeShared<AuString>(in)), offset_(offset)
CharacterProvider::CharacterProvider(const AuROString &in, AuUInt offset) :
pString_(AuMakeShared<AuString>(in)),
uOffset_(offset)
{}
CharacterProvider::CharacterProvider(const AuSPtr<AuString> &in, AuUInt offset) : string_(in), offset_(offset)
CharacterProvider::CharacterProvider(const AuSPtr<AuString> &in, AuUInt offset) :
pString_(in),
uOffset_(offset)
{}
bool CharacterProvider::GetByte(AuUInt8 &val)
{
if (!this->string_)
auto offset = this->uOffset_++;
if (offset >= this->pString_->size())
{
offset = this->pString_->size();
return false;
}
auto offset = this->offset_++;
if (offset >= this->string_->size())
{
offset = this->string_->size();
return false;
}
val = this->string_->at(offset);
val = this->pString_->at(offset);
return true;
}
AuUInt CharacterProvider::GetPosition()
{
return this->offset_;
return this->uOffset_;
}
bool CharacterProvider::SetPosition(AuUInt offset)
{
if (!this->string_)
{
return false;
}
this->offset_ = offset;
return this->offset_ < this->string_->size();
this->uOffset_ = offset;
return this->uOffset_ < this->pString_->size();
}
bool CharacterProvider::HasString()
{
return this->pString_;
}
AUKN_SYM ICharacterProviderEx *ProviderFromSharedStringNew(const AuSPtr<AuString> &str, AuUInt index)
{
SysCheckArgNotNull(str, {});
return _new CharacterProvider(str, index);
}
@ -74,9 +76,17 @@ namespace Aurora::IO::Character
AuSafeDelete<CharacterProvider *>(me);
}
AUKN_SYM ICharacterProviderEx *ProviderFromStringNew(const AuString &str, AuUInt index)
AUKN_SYM ICharacterProviderEx *ProviderFromStringNew(const AuROString &str, AuUInt index)
{
return _new CharacterProvider(str, index);
if (auto pRet = _new CharacterProvider(str, index))
{
if (pRet->HasString())
{
return pRet;
}
}
return nullptr;
}
AUKN_SYM void ProviderFromStringRelease(ICharacterProviderEx *me)

View File

@ -613,7 +613,7 @@ namespace Aurora::IO::FS
}
}
AUKN_SYM IAsyncFileStream *OpenAsyncNew(const AuString &path, EFileOpenMode openMode, AuOptional<bool> optbDirectIO, AuOptional<EFileAdvisoryLockLevel> optLock)
AUKN_SYM IAsyncFileStream *OpenAsyncNew(const AuROString &path, EFileOpenMode openMode, AuOptional<bool> optbDirectIO, AuOptional<EFileAdvisoryLockLevel> optLock)
{
auto bDirectIO = optbDirectIO.ValueOr(true);
auto lock = optLock.ValueOr(EFileAdvisoryLockLevel::eNoSafety);

View File

@ -688,7 +688,7 @@ namespace Aurora::IO::FS
}
}
AUKN_SYM IAsyncFileStream *OpenAsyncNew(const AuString &path, EFileOpenMode openMode, AuOptional<bool> optbDirectIO, AuOptional<EFileAdvisoryLockLevel> optLock)
AUKN_SYM IAsyncFileStream *OpenAsyncNew(const AuROString &path, EFileOpenMode openMode, AuOptional<bool> optbDirectIO, AuOptional<EFileAdvisoryLockLevel> optLock)
{
auto bDirectIO = optbDirectIO.ValueOr(true);
auto lock = optLock.ValueOr(EFileAdvisoryLockLevel::eNoSafety);

View File

@ -37,7 +37,7 @@ namespace Aurora::IO::FS
}
}
bool DoThing(const AuString &string)
bool DoThing(const AuROString &string)
{
AU_DEBUG_MEMCRUNCH;
@ -57,7 +57,7 @@ namespace Aurora::IO::FS
return true;
}
bool OpenDir(const AuString &str)
bool OpenDir(const AuROString &str)
{
this->curPath = str;
this->pDir = ReadDir(str);
@ -159,7 +159,7 @@ namespace Aurora::IO::FS
}
};
AUKN_SYM bool DirDeleter(const AuString &string)
AUKN_SYM bool DirDeleter(const AuROString &string)
{
auto pObj = AuMakeShared<RecursiveDirDeleter>();
SysCheckNotNullMemory(pObj, false);
@ -179,7 +179,7 @@ namespace Aurora::IO::FS
return !AuFS::DirExists(string);
}
AUKN_SYM bool DirDeleterEx(const AuString &string, AuList<AuString> &failingPaths)
AUKN_SYM bool DirDeleterEx(const AuROString &string, AuList<AuString> &failingPaths)
{
auto pObj = AuMakeShared<RecursiveDirDeleter>();
SysCheckNotNullMemory(pObj, false);
@ -195,7 +195,7 @@ namespace Aurora::IO::FS
{
for (const auto &str : pObj->failedPaths)
{
auto normalizedUserDir = string + "/";
auto normalizedUserDir = AuString(string) + "/";
auto normalizedUserDir2 = normalizedUserDir + str;
if (AuFS::FileExists(normalizedUserDir2) ||

View File

@ -15,7 +15,7 @@ namespace Aurora::IO::FS
{
static const AuUInt64 kFileCopyBlock = 0xFFFF; // 64KiB
bool _MkDir(const AuString &str)
bool _MkDir(const AuROString &str)
{
return CreateDirectoryW(Locale::ConvertFromUTF8(str).c_str(), NULL);
}
@ -112,7 +112,7 @@ namespace Aurora::IO::FS
}
};
AUKN_SYM AuSPtr<IReadDir> ReadDir(const AuString &string)
AUKN_SYM AuSPtr<IReadDir> ReadDir(const AuROString &string)
{
if (string.empty())
{
@ -149,7 +149,7 @@ namespace Aurora::IO::FS
return pObj;
}
AUKN_SYM bool FilesInDirectory(const AuString &string, AuList<AuString> &files)
AUKN_SYM bool FilesInDirectory(const AuROString &string, AuList<AuString> &files)
{
auto itr = ReadDir(string);
if (!itr)
@ -174,7 +174,7 @@ namespace Aurora::IO::FS
return true;
}
AUKN_SYM bool DirsInDirectory(const AuString &string, AuList<AuString> &dirs)
AUKN_SYM bool DirsInDirectory(const AuROString &string, AuList<AuString> &dirs)
{
auto itr = ReadDir(string);
if (!itr)
@ -199,7 +199,7 @@ namespace Aurora::IO::FS
return true;
}
AUKN_SYM bool ReadFile(const AuString &path, AuByteBuffer &buffer)
AUKN_SYM bool ReadFile(const AuROString &path, AuByteBuffer &buffer)
{
std::wstring win32Path;
LARGE_INTEGER length;
@ -293,7 +293,7 @@ namespace Aurora::IO::FS
return status;
}
AUKN_SYM bool FileExists(const AuString &path)
AUKN_SYM bool FileExists(const AuROString &path)
{
try
{
@ -321,7 +321,7 @@ namespace Aurora::IO::FS
}
}
AUKN_SYM bool DirExists(const AuString &path)
AUKN_SYM bool DirExists(const AuROString &path)
{
try
{
@ -349,7 +349,7 @@ namespace Aurora::IO::FS
}
}
AUKN_SYM bool DirMk(const AuString &path)
AUKN_SYM bool DirMk(const AuROString &path)
{
try
{
@ -375,7 +375,7 @@ namespace Aurora::IO::FS
}
}
AUKN_SYM bool Remove(const AuString &path)
AUKN_SYM bool Remove(const AuROString &path)
{
try
{
@ -432,7 +432,7 @@ namespace Aurora::IO::FS
}
}
AUKN_SYM bool Relink(const AuString &src, const AuString &dest)
AUKN_SYM bool Relink(const AuROString &src, const AuROString &dest)
{
try
{
@ -467,7 +467,7 @@ namespace Aurora::IO::FS
}
}
AUKN_SYM bool Copy(const AuString &src, const AuString &dest)
AUKN_SYM bool Copy(const AuROString &src, const AuROString &dest)
{
try
{
@ -501,7 +501,7 @@ namespace Aurora::IO::FS
}
}
AUKN_SYM bool StatFile(const AuString &path, Stat &stat)
AUKN_SYM bool StatFile(const AuROString &path, Stat &stat)
{
WIN32_FILE_ATTRIBUTE_DATA data;

View File

@ -24,7 +24,7 @@
namespace Aurora::IO::FS
{
bool _MkDir(const AuString &path)
bool _MkDir(const AuROString &path)
{
AuString subdir;
@ -150,7 +150,7 @@ namespace Aurora::IO::FS
}
};
static AuSPtr<IReadDir> ReadDirEx(const AuString &string, bool bFast)
static AuSPtr<IReadDir> ReadDirEx(const AuROString &string, bool bFast)
{
if (string.empty())
{
@ -189,12 +189,12 @@ namespace Aurora::IO::FS
return pObj;
}
AUKN_SYM AuSPtr<IReadDir> ReadDir(const AuString &string)
AUKN_SYM AuSPtr<IReadDir> ReadDir(const AuROString &string)
{
return ReadDirEx(string, false);
}
AUKN_SYM bool FilesInDirectory(const AuString &string, AuList<AuString> &files)
AUKN_SYM bool FilesInDirectory(const AuROString &string, AuList<AuString> &files)
{
auto itr = ReadDirEx(string, true);
if (!itr)
@ -219,7 +219,7 @@ namespace Aurora::IO::FS
return true;
}
AUKN_SYM bool DirsInDirectory(const AuString &string, AuList<AuString> &dirs)
AUKN_SYM bool DirsInDirectory(const AuROString &string, AuList<AuString> &dirs)
{
auto itr = ReadDirEx(string, true);
if (!itr)
@ -244,7 +244,7 @@ namespace Aurora::IO::FS
return true;
}
AUKN_SYM bool ReadFile(const AuString &path, AuByteBuffer &buffer)
AUKN_SYM bool ReadFile(const AuROString &path, AuByteBuffer &buffer)
{
AuMemoryViewWrite writeView;
@ -304,7 +304,7 @@ namespace Aurora::IO::FS
return true;
}
static bool UnixExists(const AuString &path, bool dir)
static bool UnixExists(const AuROString &path, bool dir)
{
struct stat s;
int err = ::stat(path.c_str(), &s);
@ -316,7 +316,7 @@ namespace Aurora::IO::FS
return dir ? S_ISDIR(s.st_mode) : S_ISREG(s.st_mode);
}
AUKN_SYM bool FileExists(const AuString &path)
AUKN_SYM bool FileExists(const AuROString &path)
{
if (path.empty())
{
@ -334,7 +334,7 @@ namespace Aurora::IO::FS
return UnixExists(pathExpanded, false);
}
AUKN_SYM bool DirExists(const AuString &path)
AUKN_SYM bool DirExists(const AuROString &path)
{
if (path.empty())
{
@ -352,7 +352,7 @@ namespace Aurora::IO::FS
return UnixExists(pathExpanded, true);
}
AUKN_SYM bool DirMk(const AuString &path)
AUKN_SYM bool DirMk(const AuROString &path)
{
if (path.empty())
{
@ -370,7 +370,7 @@ namespace Aurora::IO::FS
return CreateDirectories(pathExpanded, false);
}
AUKN_SYM bool Remove(const AuString &path)
AUKN_SYM bool Remove(const AuROString &path)
{
struct stat s;
@ -430,7 +430,7 @@ namespace Aurora::IO::FS
return false;
}
AUKN_SYM bool Relink(const AuString &src, const AuString &dest)
AUKN_SYM bool Relink(const AuROString &src, const AuROString &dest)
{
if (src.empty() ||
dest.empty())
@ -456,7 +456,7 @@ namespace Aurora::IO::FS
#if defined(AURORA_IS_LINUX_DERIVED)
AUKN_SYM bool Copy(const AuString &src, const AuString &dest)
AUKN_SYM bool Copy(const AuROString &src, const AuROString &dest)
{
if (src.empty() ||
dest.empty())
@ -509,7 +509,7 @@ namespace Aurora::IO::FS
#elif defined(AURORA_IS_BSD_DERIVED)
AUKN_SYM bool Copy(const AuString &src, const AuString &dest)
AUKN_SYM bool Copy(const AuROString &src, const AuROString &dest)
{
if (src.empty() ||
dest.empty())
@ -561,7 +561,7 @@ namespace Aurora::IO::FS
#else
AUKN_SYM bool Copy(const AuString &src, const AuString &dest)
AUKN_SYM bool Copy(const AuROString &src, const AuROString &dest)
{
// TODO: not that i care
return false;
@ -569,7 +569,7 @@ namespace Aurora::IO::FS
#endif
AUKN_SYM bool StatFile(const AuString &pathRel, Stat &stat)
AUKN_SYM bool StatFile(const AuROString &pathRel, Stat &stat)
{
stat = {};

View File

@ -326,7 +326,7 @@ namespace Aurora::IO::FS
}
}
AUKN_SYM bool ReadString(const AuString &path, AuString &buffer)
AUKN_SYM bool ReadString(const AuROString &path, AuString &buffer)
{
AuByteBuffer fileBuffer;
@ -338,7 +338,7 @@ namespace Aurora::IO::FS
return Locale::Encoding::DecodeUTF8(fileBuffer.data(), fileBuffer.size(), buffer, Locale::ECodePage::eUTF8).first != 0;
}
AUKN_SYM bool ReadFileHeader(const AuString &path, AuUInt16 uLength, Memory::ByteBuffer &buffer)
AUKN_SYM bool ReadFileHeader(const AuROString &path, AuUInt16 uLength, Memory::ByteBuffer &buffer)
{
AuUInt uSize {};
auto memView = buffer.GetOrAllocateLinearWriteable(uLength);
@ -352,7 +352,7 @@ namespace Aurora::IO::FS
return true;
}
AUKN_SYM bool WriteString(const AuString &path, const AuString &str)
AUKN_SYM bool WriteString(const AuROString &path, const AuROString &str)
{
char bom[3]
{
@ -383,7 +383,7 @@ namespace Aurora::IO::FS
return bOk;
}
AUKN_SYM bool WriteNewString(const AuString &path, const AuString &str)
AUKN_SYM bool WriteNewString(const AuROString &path, const AuROString &str)
{
static const char bom[3]
{
@ -428,7 +428,7 @@ namespace Aurora::IO::FS
return bOk;
}
AUKN_SYM bool WriteNewFile(const AuString &path, const Memory::MemoryViewRead &blob)
AUKN_SYM bool WriteNewFile(const AuROString &path, const Memory::MemoryViewRead &blob)
{
bool bOk {};
@ -469,7 +469,7 @@ namespace Aurora::IO::FS
return bOk;
}
AUKN_SYM bool WriteFile(const AuString &path, const Memory::MemoryViewRead &blob)
AUKN_SYM bool WriteFile(const AuROString &path, const Memory::MemoryViewRead &blob)
{
bool bOk {};
AuIO::IOHandle handle;
@ -701,7 +701,7 @@ namespace Aurora::IO::FS
}
}
AUKN_SYM bool NormalizePath(AuString &out, const AuString &in)
AUKN_SYM bool NormalizePath(AuString &out, const AuROString &in)
{
try
{
@ -714,7 +714,7 @@ namespace Aurora::IO::FS
}
}
static AuUInt GetLastSplitterIndex(const AuString &path)
static AuUInt GetLastSplitterIndex(const AuROString &path)
{
AuUInt indexA {}, indexB {};
@ -727,7 +727,7 @@ namespace Aurora::IO::FS
return AuMax(indexA, indexB);
}
AUKN_SYM bool GetFileFromPath(AuString &out, const AuString &path)
AUKN_SYM bool GetFileFromPath(AuROString &out, const AuROString &path)
{
try
{
@ -746,81 +746,74 @@ namespace Aurora::IO::FS
}
}
AUKN_SYM bool GetDirectoryFromPath(AuString &out, const AuString &path)
AUKN_SYM bool GetDirectoryFromPath(AuROString &out, const AuROString &path)
{
try
if (path.empty())
{
if (path.empty()) return false;
if (path[path.size() - 1] == '.')
{
if (path.size() > 2 && (path[path.size() - 2] == '\\' || path[path.size() - 2] == '/'))
{
out = path.substr(0, path.size() - 1);
}
else
{
return false;
}
}
return false;
}
AuUInt max = GetLastSplitterIndex(path);
if (!max)
if (path[path.size() - 1] == '.')
{
if (path.size() > 2 && (path[path.size() - 2] == '\\' || path[path.size() - 2] == '/'))
{
out = path.substr(0, path.size() - 1);
}
else
{
return false;
}
if (max == path.size())
{
out = path;
return true;
}
out = path.substr(0, max + 1);
return true;
}
catch (...)
AuUInt max = GetLastSplitterIndex(path);
if (!max)
{
out.clear();
return false;
}
if (max == path.size())
{
out = path;
return true;
}
out = path.substr(0, max + 1);
return true;
}
AUKN_SYM bool GoUpToSeparator(AuString &out, const AuString &path)
AUKN_SYM bool GoUpToSeparator(AuROString &out, const AuROString &path)
{
try
if (path.empty())
{
if (path.empty()) return false;
if (path[path.size() - 1] == '.')
{
if (path.size() > 2 && (path[path.size() - 2] == '\\' || path[path.size() - 2] == '/'))
{
out = path.substr(0, path.size() - 2);
}
else
{
return false;
}
}
return false;
}
AuUInt max = GetLastSplitterIndex(path);
if (!max)
if (path[path.size() - 1] == '.')
{
if (path.size() > 2 && (path[path.size() - 2] == '\\' || path[path.size() - 2] == '/'))
{
out = path.substr(0, path.size() - 2);
}
else
{
return false;
}
if (max == path.size())
{
out = path.substr(0, max - 1);
return true;
}
out = path.substr(0, max);
return true;
}
catch (...)
AuUInt max = GetLastSplitterIndex(path);
if (!max)
{
out.clear();
return false;
}
if (max == path.size())
{
out = path.substr(0, max - 1);
return true;
}
out = path.substr(0, max);
return true;
}
}

View File

@ -53,11 +53,11 @@ namespace Aurora::IO::FS
}
}
static auline AuString NormalizePathRet(const AuString &str)
static auline AuString NormalizePathRet(AuROString str)
{
try
{
AuString ret = str;
AuString ret = AuString(str);
_NormalizePath(ret);
return ret;
}
@ -67,14 +67,14 @@ namespace Aurora::IO::FS
}
}
bool _MkDir(const AuString &str);
bool _MkDir(const AuROString &str);
static bool CreateDirectories(const AuString &cpath, bool isFile)
static bool CreateDirectories(const AuROString &cpath, bool isFile)
{
try
{
// This gives us a significant performance boost
AuString path;
AuROString path;
if (isFile && GetDirectoryFromPath(path, cpath))
{
if (DirExists(path))
@ -89,7 +89,7 @@ namespace Aurora::IO::FS
if ((cpath[i] == kPathSplitter) ||
((!isFile) && (end)))
{
auto subpath = end ? cpath : AuString(cpath.begin(), cpath.begin() + i);
auto subpath = end ? AuString(cpath) : AuString(cpath.begin(), cpath.begin() + i);
if (subpath.empty())
{
continue;

View File

@ -16,7 +16,7 @@ namespace Aurora::IO::FS
static auto const kCompressionType = AuCompression::ECompressionType::eZSTD;
static const AuString kStringSuffix = ".zst";
static bool CompressEx2(const AuString &path, const AuString &suffix, AuCompression::ECompressionType type, AuInt8 level, bool bCheck)
static bool CompressEx2(const AuROString &path, const AuROString &suffix, AuCompression::ECompressionType type, AuInt8 level, bool bCheck)
{
static const auto kCompressionReadChunks = kFileCopyBlock;
@ -42,14 +42,16 @@ namespace Aurora::IO::FS
return {};
}
AuString fullA(AuString(path) + AuString(suffix));
auto qwLength = pFileSrc->GetLength();
if (!qwLength)
{
pFileSrc->Close();
return AuFS::Relink(path, path + suffix);
return AuFS::Relink(path, fullA);
}
auto pFileDest = OpenWriteShared(path + suffix, EFileAdvisoryLockLevel::eBlockReadWrite);
auto pFileDest = OpenWriteShared(fullA, EFileAdvisoryLockLevel::eBlockReadWrite);
if (!pFileDest)
{
SysPushErrorIO("Couldn't open compression destination path: {}{}", path, suffix);
@ -62,7 +64,6 @@ namespace Aurora::IO::FS
return {};
}
auto pFileStream = AuMakeShared<AuIO::FS::FileReader>(pFileSrc);
SysCheckNotNullMemory(pFileStream, {});
@ -145,17 +146,17 @@ namespace Aurora::IO::FS
return qwTotalRead == qwLength;
}
AUKN_SYM bool CompressEx(const AuString &path, const AuString &suffix, AuCompression::ECompressionType type, AuInt8 level)
AUKN_SYM bool CompressEx(const AuROString &path, const AuROString &suffix, AuCompression::ECompressionType type, AuInt8 level)
{
return CompressEx2(path, kStringSuffix, kCompressionType, level, false);
}
AUKN_SYM bool Compress(const AuString &path, AuInt8 level)
AUKN_SYM bool Compress(const AuROString &path, AuInt8 level)
{
return CompressEx2(path, kStringSuffix, kCompressionType, level, true);
}
AUKN_SYM bool DecompressEx(const AuString &path, const AuString &suffix, AuCompression::ECompressionType type)
AUKN_SYM bool DecompressEx(const AuROString &path, const AuROString &suffix, AuCompression::ECompressionType type)
{
static const auto kCompressionReadChunks = kFileCopyBlock;
@ -165,7 +166,9 @@ namespace Aurora::IO::FS
return {};
}
auto pFileSrc = OpenReadShared(path + suffix, EFileAdvisoryLockLevel::eBlockWrite);
AuString fullA(AuString(path) + AuString(suffix));
auto pFileSrc = OpenReadShared(fullA, EFileAdvisoryLockLevel::eBlockWrite);
if (!pFileSrc)
{
SysPushErrorIO("Couldn't open compression source path: {}{}", path, suffix);
@ -176,7 +179,7 @@ namespace Aurora::IO::FS
if (!qwLength)
{
pFileSrc->Close();
return AuFS::Relink(path + suffix, path);
return AuFS::Relink(fullA, path);
}
auto pFileDest = OpenWriteShared(path, EFileAdvisoryLockLevel::eBlockReadWrite);
@ -256,7 +259,7 @@ namespace Aurora::IO::FS
return qwTotalRead == qwLength;
}
AUKN_SYM bool Decompress(const AuString &path)
AUKN_SYM bool Decompress(const AuROString &path)
{
return DecompressEx(path, kStringSuffix, kCompressionType);
}

View File

@ -30,14 +30,14 @@ namespace Aurora::IO::FS
return this->failedPaths;
}
bool OpenDir(const AuString &str)
bool OpenDir(const AuROString &str)
{
curPath = str;
pDir = ReadDir(str);
return bool(pDir);
}
bool OpenNext(const AuString &str)
bool OpenNext(const AuROString &str)
{
curPath = str;
pDir = ReadDir(str);
@ -121,7 +121,7 @@ namespace Aurora::IO::FS
}
};
AUKN_SYM AuSPtr<IReadDir> ReadDirRecursive(const AuString &string, AuOptional<bool> bTraverseSymlinks)
AUKN_SYM AuSPtr<IReadDir> ReadDirRecursive(const AuROString &string, AuOptional<bool> bTraverseSymlinks)
{
auto pObj = AuMakeShared<RecursiveDirIterator>();
if (!pObj)

View File

@ -25,7 +25,7 @@ namespace Aurora::IO::FS
return temp;
}
AUKN_SYM bool UpdateFileTimes(const AuString &path, const UpdateTimes &times)
AUKN_SYM bool UpdateFileTimes(const AuROString &path, const UpdateTimes &times)
{
HANDLE hFile;
FILETIME created;

View File

@ -31,7 +31,7 @@ namespace Aurora::IO::FS
temp->tv_usec = ts.tv_nsec / 1'000ull;
}
AUKN_SYM bool UpdateFileTimes(const AuString &path, const UpdateTimes &times)
AUKN_SYM bool UpdateFileTimes(const AuROString &path, const UpdateTimes &times)
{
if (times.createdNs)
{

View File

@ -11,7 +11,7 @@
namespace Aurora::IO::FS
{
AUKN_SYM AuList<AuString> FileAttrsList(const AuString &path)
AUKN_SYM AuList<AuString> FileAttrsList(const AuROString &path)
{
AuList<AuString> names;
WIN32_FIND_STREAM_DATA data;
@ -108,25 +108,46 @@ namespace Aurora::IO::FS
return names;
}
AUKN_SYM AuResult<Memory::ByteBuffer> FileAttrsGet(const AuString &path, const AuString &attr)
AUKN_SYM AuResult<Memory::ByteBuffer> FileAttrsGet(const AuROString &path, const AuROString &attr)
{
AuByteBuffer temp;
try
{
AuByteBuffer temp;
if (!AuFS::ReadFile(path + ":" + attr, temp))
if (!AuFS::ReadFile(AuString(path) + ":" + AuString(attr), temp))
{
return {};
}
return AuMove(temp);
}
catch (...)
{
return {};
}
return AuMove(temp);
}
AUKN_SYM bool FileAttrsSet(const AuString &path, const AuString &attr, const Memory::MemoryViewRead &view)
AUKN_SYM bool FileAttrsSet(const AuROString &path, const AuROString &attr, const Memory::MemoryViewRead &view)
{
return AuFS::WriteFile(path + ":" + attr, view);
try
{
return AuFS::WriteFile(AuString(path) + ":" + AuString(attr), view);
}
catch (...)
{
return false;
}
}
AUKN_SYM bool FileAttrsDel(const AuString &path, const AuString &attr)
AUKN_SYM bool FileAttrsDel(const AuROString &path, const AuROString &attr)
{
return AuFS::Remove(path + ":" + attr) || AuFS::FileExists(path);
try
{
return AuFS::Remove(AuString(path) + ":" + AuString(attr)) || AuFS::FileExists(path);
}
catch (...)
{
return false;
}
}
}

View File

@ -13,7 +13,7 @@
namespace Aurora::IO::FS
{
AUKN_SYM AuList<AuString> FileAttrsList(const AuString &path)
AUKN_SYM AuList<AuString> FileAttrsList(const AuROString &path)
{
static const auto kLength = 10 * 1024;
AuString buffer;
@ -43,11 +43,12 @@ namespace Aurora::IO::FS
return {};
}
return AuSplitString(buffer, "\00");
return AuSplitStringLegacy(buffer, "\00");
}
AUKN_SYM AuResult<AuByteBuffer> FileAttrsGet(const AuString &path, const AuString &attr)
AUKN_SYM AuResult<AuByteBuffer> FileAttrsGet(const AuROString &path, const AuROString &attr)
{
AuString copy(attr);
AuByteBuffer buffer;
auto srcPath = NormalizePathRet(path);
@ -56,7 +57,7 @@ namespace Aurora::IO::FS
return {};
}
auto length = ::getxattr(srcPath.c_str(), attr.c_str(), nullptr, 0);
auto length = ::getxattr(srcPath.c_str(), copy.c_str(), nullptr, 0);
if (length < 0)
{
SysPushErrorIO("Error reading attribute");
@ -74,7 +75,7 @@ namespace Aurora::IO::FS
return {};
}
length = ::getxattr(srcPath.c_str(), attr.c_str(), buffer.base, length);
length = ::getxattr(srcPath.c_str(), copy.c_str(), buffer.base, length);
if (length < 0)
{
SysPushErrorIO("Error reading attribute");
@ -86,19 +87,21 @@ namespace Aurora::IO::FS
return AuMove(buffer);
}
AUKN_SYM bool FileAttrsSet(const AuString &path, const AuString &attr, const Memory::MemoryViewRead &view)
AUKN_SYM bool FileAttrsSet(const AuROString &path, const AuROString &attr, const Memory::MemoryViewRead &view)
{
AuString copy(attr);
auto srcPath = NormalizePathRet(path);
if (srcPath.empty())
{
return false;
}
if (::setxattr(srcPath.c_str(), attr.c_str(), view.ptr, view.length, XATTR_CREATE) == -1)
if (::setxattr(srcPath.c_str(), copy.c_str(), view.ptr, view.length, XATTR_CREATE) == -1)
{
if (errno == EEXIST)
{
if (::setxattr(srcPath.c_str(), attr.c_str(), view.ptr, view.length, XATTR_REPLACE) == -1)
if (::setxattr(srcPath.c_str(), copy.c_str(), view.ptr, view.length, XATTR_REPLACE) == -1)
{
SysPushErrorIO();
return false;
@ -109,15 +112,17 @@ namespace Aurora::IO::FS
return true;
}
AUKN_SYM bool FileAttrsDel(const AuString &path, const AuString &attr)
AUKN_SYM bool FileAttrsDel(const AuROString &path, const AuROString &attr)
{
AuString copy(attr);
auto srcPath = NormalizePathRet(path);
if (srcPath.empty())
{
return false;
}
return (::removexattr(srcPath.c_str(), attr.c_str()) == 0) ||
return (::removexattr(srcPath.c_str(), copy.c_str()) == 0) ||
(errno == ENODATA);
}
}

View File

@ -566,7 +566,7 @@ namespace Aurora::IO::FS
AuSafeDelete<WinFileStream *>(that);
}
static IFileStream *OpenNewEx(const AuString &path,
static IFileStream *OpenNewEx(const AuROString &path,
EFileOpenMode openMode,
EFileAdvisoryLockLevel lock,
bool bCheck)
@ -609,7 +609,7 @@ namespace Aurora::IO::FS
}
}
AUKN_SYM IFileStream *CreateNew(const AuString &path)
AUKN_SYM IFileStream *CreateNew(const AuROString &path)
{
return OpenNewEx(path, EFileOpenMode::eWrite, EFileAdvisoryLockLevel::eBlockReadWrite, true);
}
@ -619,7 +619,7 @@ namespace Aurora::IO::FS
AuSafeDelete<WinFileStream *>(that);
}
AUKN_SYM IFileStream *OpenNew(const AuString &path, EFileOpenMode openMode, EFileAdvisoryLockLevel lock)
AUKN_SYM IFileStream *OpenNew(const AuROString &path, EFileOpenMode openMode, EFileAdvisoryLockLevel lock)
{
return OpenNewEx(path, openMode, lock, false);
}
@ -629,7 +629,7 @@ namespace Aurora::IO::FS
AuSafeDelete<WinFileStream *>(that);
}
AUKN_SYM IFileStream *OpenReadNew(const AuString &path, EFileAdvisoryLockLevel level)
AUKN_SYM IFileStream *OpenReadNew(const AuROString &path, EFileAdvisoryLockLevel level)
{
return OpenNew(path, EFileOpenMode::eRead, level);
}
@ -639,7 +639,7 @@ namespace Aurora::IO::FS
AuSafeDelete<WinFileStream *>(that);
}
AUKN_SYM IFileStream *OpenWriteNew(const AuString &path, EFileAdvisoryLockLevel level)
AUKN_SYM IFileStream *OpenWriteNew(const AuROString &path, EFileAdvisoryLockLevel level)
{
return OpenNew(path, EFileOpenMode::eWrite, level);
}

View File

@ -476,7 +476,7 @@ namespace Aurora::IO::FS
}
}
AUKN_SYM IFileStream *CreateNew(const AuString &path)
AUKN_SYM IFileStream *CreateNew(const AuROString &path)
{
return OpenNewEx(path, EFileOpenMode::eWrite, EFileAdvisoryLockLevel::eBlockReadWrite, true);
}
@ -486,7 +486,7 @@ namespace Aurora::IO::FS
AuSafeDelete<PosixFileStream *>(that);
}
AUKN_SYM IFileStream *OpenNew(const AuString &path, EFileOpenMode openMode, EFileAdvisoryLockLevel lock)
AUKN_SYM IFileStream *OpenNew(const AuROString &path, EFileOpenMode openMode, EFileAdvisoryLockLevel lock)
{
return OpenNewEx(path, openMode, lock, false);
}
@ -496,7 +496,7 @@ namespace Aurora::IO::FS
AuSafeDelete<PosixFileStream *>(that);
}
AUKN_SYM IFileStream *OpenReadNew(const AuString &path, EFileAdvisoryLockLevel level)
AUKN_SYM IFileStream *OpenReadNew(const AuROString &path, EFileAdvisoryLockLevel level)
{
return OpenNewEx(path, EFileOpenMode::eRead, level, false);
}
@ -506,7 +506,7 @@ namespace Aurora::IO::FS
AuSafeDelete<PosixFileStream *>(that);
}
AUKN_SYM IFileStream *OpenWriteNew(const AuString &path, EFileAdvisoryLockLevel level)
AUKN_SYM IFileStream *OpenWriteNew(const AuROString &path, EFileAdvisoryLockLevel level)
{
return OpenNewEx(path, EFileOpenMode::eWrite, level, false);
}

View File

@ -11,21 +11,21 @@
namespace Aurora::IO::FS
{
AUKN_SYM bool BlockFile(const AuString &path)
AUKN_SYM bool BlockFile(const AuROString &path)
{
return AuFS::WriteFile(path + ":Zone.Identifier", "[ZoneTransfer]\r\nZoneId=3\r\n");
return AuFS::WriteFile(AuString(path) + ":Zone.Identifier", "[ZoneTransfer]\r\nZoneId=3\r\n");
}
AUKN_SYM bool UnblockFile(const AuString &path)
AUKN_SYM bool UnblockFile(const AuROString &path)
{
return AuFS::WriteFile(path + ":Zone.Identifier", "[ZoneTransfer]\r\nZoneId=0\r\n");
return AuFS::WriteFile(AuString(path) + ":Zone.Identifier", "[ZoneTransfer]\r\nZoneId=0\r\n");
}
AUKN_SYM bool TrustFile(const AuString &path)
AUKN_SYM bool TrustFile(const AuROString &path)
{
AuString idc;
auto uri = path + ":Zone.Identifier";
auto uri = AuString(path) + ":Zone.Identifier";
if (AuFS::FileExists(uri))
{
@ -38,11 +38,11 @@ namespace Aurora::IO::FS
return true;
}
AUKN_SYM bool IsFileBlocked(const AuString &path)
AUKN_SYM bool IsFileBlocked(const AuROString &path)
{
AuString content;
auto uri = path + ":Zone.Identifier";
auto uri = AuString(path) + ":Zone.Identifier";
if (!AuFS::FileExists(uri))
{
return !AuFS::FileExists(path);
@ -58,11 +58,11 @@ namespace Aurora::IO::FS
AuStringContains(content, "ZoneId=4\r\n"); // untrusted
}
AUKN_SYM bool IsFileTrusted(const AuString &path)
AUKN_SYM bool IsFileTrusted(const AuROString &path)
{
AuString content;
auto uri = path + ":Zone.Identifier";
auto uri = AuString(path) + ":Zone.Identifier";
if (!AuFS::FileExists(uri))
{

View File

@ -17,7 +17,7 @@
namespace Aurora::IO::FS
{
AUKN_SYM bool BlockFile(const AuString &path)
AUKN_SYM bool BlockFile(const AuROString &path)
{
auto srcPath = NormalizePathRet(path);
if (srcPath.empty())
@ -81,7 +81,7 @@ namespace Aurora::IO::FS
return true;
}
AUKN_SYM bool UnblockFile(const AuString &path)
AUKN_SYM bool UnblockFile(const AuROString &path)
{
auto srcPath = NormalizePathRet(path);
if (srcPath.empty())
@ -136,7 +136,7 @@ namespace Aurora::IO::FS
return true;
}
AUKN_SYM bool IsFileBlocked(const AuString &path)
AUKN_SYM bool IsFileBlocked(const AuROString &path)
{
auto srcPath = NormalizePathRet(path);
if (srcPath.empty())
@ -160,7 +160,7 @@ namespace Aurora::IO::FS
return false;
}
AUKN_SYM bool IsFileTrusted(const AuString &path)
AUKN_SYM bool IsFileTrusted(const AuROString &path)
{
struct stat s;
auto srcPath = NormalizePathRet(path);

View File

@ -545,7 +545,9 @@ namespace Aurora::IO::FS
if (AuIOFS::FileExists(translated))
{
AuIOFS::GetDirectoryFromPath(translated, translated);
AuROString out;
AuIOFS::GetDirectoryFromPath(out, translated);
translated = out;
}
else
{

View File

@ -74,7 +74,7 @@ namespace Aurora::Locale
return {};
}
AUKN_SYM std::wstring ConvertFromUTF8(const AuString &in)
AUKN_SYM std::wstring ConvertFromUTF8(const AuROString &in)
{
AU_DEBUG_MEMCRUNCH;
@ -82,7 +82,7 @@ namespace Aurora::Locale
{
#if defined(AU_HAS_MSFT_NATIONALLANGSUPPORT)
std::wstring ret;
auto chars = MultiByteToWideChar(CP_UTF8, 0, in.c_str(), in.length(), NULL, 0);
auto chars = MultiByteToWideChar(CP_UTF8, 0, in.data(), in.length(), NULL, 0);
if (!chars)
{
@ -90,7 +90,7 @@ namespace Aurora::Locale
}
ret.resize(chars);
MultiByteToWideChar(CP_UTF8, 0, in.c_str(), in.length(), ret.data(), ret.size());
MultiByteToWideChar(CP_UTF8, 0, in.data(), in.length(), ret.data(), ret.size());
return ret;
#elif !defined(AU_NO_CPPLOCALE)
return gUtf8Conv.from_bytes(in);

View File

@ -47,7 +47,7 @@ namespace Aurora::Logging
else [[unlikely]]
{
Parse::SplitNewlines(msg.line,
[&](const AuString &line)
[&](const AuROString &line)
{
ConsoleMessage dup = msg;
dup.line = line;

View File

@ -11,7 +11,7 @@
namespace Aurora::Parse
{
AUKN_SYM bool Base32Decode(const AuString &in, AuByteBuffer &decoded)
AUKN_SYM bool Base32Decode(const AuROString &in, AuByteBuffer &decoded)
{
int iRet;
unsigned long uLength = in.size();
@ -23,9 +23,9 @@ namespace Aurora::Parse
return false;
}
iRet = ::base32_decode(AuReinterpretCast<const char *>(decoded.writePtr),
iRet = ::base32_decode(AuReinterpretCast<const char *>(in.data()),
(unsigned long)uLength,
AuReinterpretCast<unsigned char *>(&decoded[0]),
AuReinterpretCast<unsigned char *>(decoded.writePtr),
&uLength,
BASE32_RFC4648);
if (iRet != CRYPT_OK)

View File

@ -11,7 +11,7 @@
namespace Aurora::Parse
{
AUKN_SYM bool Base64Decode(const AuString &in, AuByteBuffer &decoded, bool bUrl)
AUKN_SYM bool Base64Decode(const AuROString &in, AuByteBuffer &decoded, bool bUrl)
{
int iRet;
unsigned long uLength = (unsigned long)in.size();
@ -25,16 +25,16 @@ namespace Aurora::Parse
if (bUrl)
{
iRet = ::base64url_decode(AuReinterpretCast<const char *>(decoded.writePtr),
iRet = ::base64url_decode(AuReinterpretCast<const char *>(in.data()),
(unsigned long)uLength,
AuReinterpretCast<unsigned char *>(&decoded[0]),
AuReinterpretCast<unsigned char *>(decoded.writePtr),
&uLength);
}
else
{
iRet = ::base64_decode(AuReinterpretCast<const char *>(decoded.writePtr),
iRet = ::base64_decode(AuReinterpretCast<const char *>(in.data()),
(unsigned long)uLength,
AuReinterpretCast<unsigned char *>(&decoded[0]),
AuReinterpretCast<unsigned char *>(decoded.writePtr),
&uLength);
}

View File

@ -41,8 +41,11 @@ namespace Aurora::Parse
return true;
}
AUKN_SYM bool HexToInt(const char *pHex, AuUInt32 uLength, AuUInt64 &val)
AUKN_SYM bool HexToInt(const AuROString &hex, AuUInt64 &val)
{
auto pHex = hex.data();
auto uLength = hex.length();
val = 0;
uLength = AuMin(AuUInt32(sizeof(AuUInt64) * 2), uLength);
@ -100,7 +103,7 @@ namespace Aurora::Parse
hex[1] = NibbleToChar(lowNibble);
}
AUKN_SYM bool DecodeHex(const AuString &in, AuByteBuffer &out)
AUKN_SYM bool DecodeHex(const AuROString &in, AuByteBuffer &out)
{
#define HEX_GRAMMAR_CONSUME_ALL(x) \
for (; i < in.size(); i++) \

View File

@ -849,11 +849,11 @@ namespace Aurora::Parse
return res;
}
AUKN_SYM AuResult<AuSInt> ParseSInt16(const AuString &str)
AUKN_SYM AuResult<AuSInt> ParseSInt16(const AuROString &str)
{
const char *didntFuckingAskTYVM { &str[str.size()] };
auto res = ParseSInt16(str.c_str(), didntFuckingAskTYVM);
auto res = ParseSInt16(str.data(), didntFuckingAskTYVM);
if (!res.has_value())
{
return {};
@ -886,11 +886,11 @@ namespace Aurora::Parse
return res;
}
AUKN_SYM AuResult<AuUInt> ParseUInt16(const AuString &str)
AUKN_SYM AuResult<AuUInt> ParseUInt16(const AuROString &str)
{
const char *didntFuckingAskTYVM { &str[str.size()] };
auto res = ParseUInt16(str.c_str(), didntFuckingAskTYVM);
auto res = ParseUInt16(str.data(), didntFuckingAskTYVM);
if (!res.has_value())
{
return {};
@ -904,11 +904,11 @@ namespace Aurora::Parse
return res;
}
AUKN_SYM AuResult<AuSInt> ParseSInt(const AuString &str)
AUKN_SYM AuResult<AuSInt> ParseSInt(const AuROString &str)
{
const char *didntFuckingAskTYVM { &str[str.size()] };
auto res = ParseSInt(str.c_str(), didntFuckingAskTYVM);
auto res = ParseSInt(str.data(), didntFuckingAskTYVM);
if (!res.has_value())
{
return {};
@ -941,11 +941,11 @@ namespace Aurora::Parse
return res;
}
AUKN_SYM AuResult<AuUInt> ParseUInt(const AuString &str)
AUKN_SYM AuResult<AuUInt> ParseUInt(const AuROString &str)
{
const char *didntFuckingAskTYVM { &str[str.size()] };
auto res = ParseUInt(str.c_str(), didntFuckingAskTYVM);
auto res = ParseUInt(str.data(), didntFuckingAskTYVM);
if (!res.has_value())
{
return {};

View File

@ -103,7 +103,7 @@ namespace Aurora::Processes
}
}
static void UnixOpenAsync(const AuString &uri, bool bType)
static void UnixOpenAsync(const AuROString &uri, bool bType)
{
if (uri.empty())
{
@ -113,12 +113,12 @@ namespace Aurora::Processes
AuThreads::Spawn(std::bind(&UnixOpenAsyncThread, AuString(uri), bType), true);
}
AUKN_SYM void OpenUri(const AuString &uri)
AUKN_SYM void OpenUri(const AuROString &uri)
{
UnixOpenAsync(uri, true);
}
AUKN_SYM void OpenFile(const AuString &file)
AUKN_SYM void OpenFile(const AuROString &file)
{
UnixOpenAsync(file, false);
}

View File

@ -132,14 +132,14 @@ namespace Aurora::Processes
gOpenerThread.reset();
}
AUKN_SYM void OpenUri(const AuString &uri)
AUKN_SYM void OpenUri(const AuROString &uri)
{
AU_LOCK_GUARD(gCondMutex);
AuTryInsert(gOpenItems, AuMakePair(uri, true));
AuTryInsert(gOpenItems, AuMakePair(AuString(uri), true));
gCondVariable->Signal();
}
AUKN_SYM void OpenFile(const AuString &file)
AUKN_SYM void OpenFile(const AuROString &file)
{
auto path = AuIOFS::NormalizePathRet(file);