code review refactoring
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "ExeAppendedZipLoaderLinux.hpp"
|
||||
#include "ExeAppendedZipResourceLoaderLinux.hpp"
|
||||
#include <unistd.h>
|
||||
#include <climits>
|
||||
|
||||
@@ -12,19 +12,15 @@ namespace OpenVulkano
|
||||
{
|
||||
namespace
|
||||
{
|
||||
void* HANDLE = ResourceLoader::RegisterResourceLoader(std::make_unique<ExeAppendedZipLoaderLinux>());
|
||||
void* HANDLE = ResourceLoader::RegisterResourceLoader(std::make_unique<ExeAppendedZipResourceLoaderLinux>());
|
||||
}
|
||||
|
||||
std::string OpenVulkano::ExeAppendedZipLoaderLinux::GetCurrentExecutablePath() const
|
||||
std::string OpenVulkano::ExeAppendedZipResourceLoaderLinux::GetCurrentExecutablePath() const
|
||||
{
|
||||
char dest[PATH_MAX];
|
||||
memset(dest, 0, sizeof(dest)); // readlink does not null terminate!
|
||||
size_t sz = 0;
|
||||
if ((sz = readlink("/proc/self/exe", dest, PATH_MAX)) != -1)
|
||||
{
|
||||
return std::string(dest, sz);
|
||||
}
|
||||
return "";
|
||||
std::string path(PATH_MAX, '\0');
|
||||
ssize_t sz = readlink("/proc/self/exe", path.data(), path.capacity()));
|
||||
path.resize(std::max<ssize_t>(0, sz));
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user