tyrav2 init

This commit is contained in:
h4570
2022-07-17 10:21:35 +02:00
parent 44c1ee4fe8
commit c8b22ff331
249 changed files with 18187 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020 - 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Wellington Carvalho <wellcoj@gmail.com>
*/
#include "debug/debug.hpp"
#include <tamtypes.h>
#include <cstdio>
#include <kernel.h>
#include <limits.h>
#include <syslimits.h>
#include <unistd.h>
#include <cstring>
#include "file/file_utils.hpp"
namespace Tyra {
FileUtils::FileUtils() {
getcwd(cwd, sizeof(cwd));
setPathInfo(cwd);
}
FileUtils::~FileUtils() {}
void FileUtils::setPathInfo(const char* path) {
char* ptr;
strcpy(this->elfName, path);
strcpy(this->elfPath, path);
ptr = strrchr(this->elfPath, '/');
if (ptr == NULL) {
ptr = strrchr(this->elfPath, '\\');
if (ptr == NULL) {
ptr = strrchr(this->elfPath, ':');
if (ptr == NULL) {
TYRA_TRAP("Did not find path! PATH: ", path);
}
}
}
ptr++;
*ptr = '\0';
}
std::string FileUtils::getCwd() {
std::string result;
char _cwd[NAME_MAX];
getcwd(_cwd, sizeof(_cwd));
result = _cwd;
return result;
}
std::string FileUtils::fromCwd(const char* file) {
auto cwd = getCwd();
return cwd + file;
}
} // namespace Tyra