flatten 20260225
This commit is contained in:
71
tjp/core/file/apple/Directories.cpp
Normal file
71
tjp/core/file/apple/Directories.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
// TJP COPYRIGHT HEADER
|
||||
|
||||
#include "Directories.h"
|
||||
#include "../Path.h"
|
||||
|
||||
#include <tjp/core/system/System.h>
|
||||
|
||||
#ifdef SYS_MAC
|
||||
#include <mach-o/dyld.h>
|
||||
#include "CoreFoundation/CFBundle.h"
|
||||
#endif
|
||||
|
||||
#ifdef SYS_IOS
|
||||
#include <mach-o/dyld.h>
|
||||
#include "CoreFoundation/CFBundle.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
namespace tjp {
|
||||
namespace core {
|
||||
namespace file {
|
||||
namespace apple {
|
||||
|
||||
std::string getHomeDirectory ()
|
||||
{
|
||||
const char *homeDir = getenv("HOME");
|
||||
if (homeDir)
|
||||
return homeDir;
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string getExecutablePath ()
|
||||
{
|
||||
char path_[PATH_MAX+1];
|
||||
|
||||
uint32_t size=PATH_MAX;
|
||||
_NSGetExecutablePath(path_, &size);
|
||||
if (size > 0)
|
||||
{
|
||||
auto path = std::string(path_);
|
||||
return path;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string getExecutableDirectory ()
|
||||
{
|
||||
auto path = getExecutablePath();
|
||||
return popFileName(path);
|
||||
}
|
||||
|
||||
std::string getExecutableBundleDirectory ()
|
||||
{
|
||||
return popLast(getExecutableDirectory());
|
||||
}
|
||||
|
||||
std::string getExecutableResourceDirectory ()
|
||||
{
|
||||
auto path = getExecutableBundleDirectory();
|
||||
return joinDirs({ path, "Resources"});
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
} // namespace
|
||||
} // namespace
|
||||
22
tjp/core/file/apple/Directories.h
Normal file
22
tjp/core/file/apple/Directories.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// TJP COPYRIGHT HEADER
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace tjp {
|
||||
namespace core {
|
||||
namespace file {
|
||||
namespace apple {
|
||||
|
||||
std::string getExecutablePath();
|
||||
std::string getExecutableDirectory();
|
||||
std::string getExecutableBundleDirectory();
|
||||
std::string getExecutableResourceDirectory();
|
||||
std::string getHomeDirectory();
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
} // namespace
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user