[*] Refactor AuProcess paths to return AuOptional<const AuString &>

(because the previous iteration was using a pointer, dereference and operator bool() semantics still apply. no changes required, except for direct access of the string buffer, but no instances of the -> operator were found)
This commit is contained in:
Reece Wilson 2024-02-14 04:05:32 +00:00
parent 03623dfa48
commit f049053776
2 changed files with 13 additions and 13 deletions

View File

@ -20,17 +20,17 @@ namespace Aurora::Process
* @brief Fetches the applications binary or package directory
* @return
*/
AUKN_SYM const AuString *GetProcessDirectory();
AUKN_SYM AuOptional<const AuString &> GetProcessDirectory();
/**
* @brief Fetches the full-path of the applications binary, if known
* @return
*/
AUKN_SYM const AuString *GetProcessFullPath();
AUKN_SYM AuOptional<const AuString &> GetProcessFullPath();
/**
* @brief Fetches the applications primary module name
* @return
*/
AUKN_SYM const AuString *GetProcessName();
AUKN_SYM AuOptional<const AuString &> GetProcessName();
}

View File

@ -246,7 +246,7 @@ namespace Aurora::Process
return true;
}
AUKN_SYM const AuString *GetProcessName()
AUKN_SYM AuOptional<const AuString &> GetProcessName()
{
const AuString *pModule, *pPartial, *pFull;
@ -256,7 +256,7 @@ namespace Aurora::Process
pModule &&
pModule->size())
{
return pModule;
return *pModule;
}
}
catch (...)
@ -264,10 +264,10 @@ namespace Aurora::Process
SysPushErrorCatch();
}
return nullptr;
return {};
}
AUKN_SYM const AuString *GetProcessDirectory()
AUKN_SYM AuOptional<const AuString &> GetProcessDirectory()
{
const AuString *pModule, *pPartial, *pFull;
@ -277,7 +277,7 @@ namespace Aurora::Process
pPartial &&
pPartial->size())
{
return pPartial;
return *pPartial;
}
{
@ -291,7 +291,7 @@ namespace Aurora::Process
if (cwd.size())
{
return &cwd;
return cwd;
}
}
}
@ -300,10 +300,10 @@ namespace Aurora::Process
SysPushErrorCatch();
}
return nullptr;
return {};
}
AUKN_SYM const AuString *GetProcessFullPath()
AUKN_SYM AuOptional<const AuString &> GetProcessFullPath()
{
const AuString *pModule, *pPartial, *pFull;
@ -313,7 +313,7 @@ namespace Aurora::Process
pFull &&
pFull->size())
{
return pFull;
return *pFull;
}
}
catch (...)
@ -321,6 +321,6 @@ namespace Aurora::Process
SysPushErrorCatch();
}
return nullptr;
return {};
}
}