Added portable app support

This commit is contained in:
2026-01-11 17:06:01 -06:00
parent 7dc4ad9b08
commit 2f5271f7c3
13 changed files with 760 additions and 6 deletions

View File

@@ -0,0 +1,7 @@
FROM onedev.site.tesses.net/tesses-framework/tesses-framework:latest
COPY ./portable-json-creator /wwwroot
EXPOSE 4999
ENTRYPOINT ["tfileserver","--port","4999","/wwwroot"]

View File

@@ -0,0 +1,5 @@
services:
portable-json:
image: onedev.site.tesses.net/tesses-framework/portable-json-creator:latest
ports:
- "4999:4999"

View File

@@ -13,6 +13,7 @@
namespace Tesses::Framework namespace Tesses::Framework
{ {
template<typename...TArgs> template<typename...TArgs>
class Event { class Event {
public: public:
@@ -90,6 +91,7 @@ namespace Tesses::Framework
extern EventList<uint64_t> OnItteraton; extern EventList<uint64_t> OnItteraton;
std::optional<std::string> TF_GetCommandName(); std::optional<std::string> TF_GetCommandName();
void TF_Init(); void TF_Init();
void TF_InitWithConsole(); void TF_InitWithConsole();
void TF_AllowPortable(std::string argv0); void TF_AllowPortable(std::string argv0);

View File

@@ -6,7 +6,23 @@ namespace Tesses::Framework::Platform::Environment
{ {
extern const char EnvPathSeperator; extern const char EnvPathSeperator;
struct PortableAppConfig {
std::optional<Tesses::Framework::Filesystem::VFSPath> desktop;
std::optional<Tesses::Framework::Filesystem::VFSPath> documents;
std::optional<Tesses::Framework::Filesystem::VFSPath> music;
std::optional<Tesses::Framework::Filesystem::VFSPath> pictures;
std::optional<Tesses::Framework::Filesystem::VFSPath> videos;
std::optional<Tesses::Framework::Filesystem::VFSPath> downloads;
std::optional<Tesses::Framework::Filesystem::VFSPath> user;
std::optional<Tesses::Framework::Filesystem::VFSPath> config;
std::optional<Tesses::Framework::Filesystem::VFSPath> state;
std::optional<Tesses::Framework::Filesystem::VFSPath> data;
std::optional<Tesses::Framework::Filesystem::VFSPath> cache;
std::optional<Tesses::Framework::Filesystem::VFSPath> temp;
};
extern PortableAppConfig portable_config;
namespace SpecialFolders { namespace SpecialFolders {
Tesses::Framework::Filesystem::VFSPath GetTemp(); Tesses::Framework::Filesystem::VFSPath GetTemp();

View File

@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TessesFramework portable.json creator</title>
</head>
<body>
<h1>TessesFramework portable.json creator</h1>
Choose the way you want your app to be portable
<ul>
<li>
<a href="./portableapps/">
PortableApps.com
</a>
</li>
<li>
<a href="./relative/">
Relative To Application
</a>
</li>
</ul>
</body>
</html>

View File

@@ -0,0 +1,98 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TessesFramework portable.json creator</title>
</head>
<body>
<h1>TessesFramework portable.json creator</h1>
Don&apos;t want PortableApps.com click <a href="../relative/">here</a> for just having directories relative to application
<fieldset>
<legend>Configuration</legend>
<label for="user">TF_User: </label>
<select id="user">
<option value="system">System&apos;s %USERPROFILE%</option>
<option value="app">MyApp\Data\TF_User (tied to app)</option>
<option value="documents" selected>PAF\Documents\TF_User (shared between all tessesframework portable apps)</option>
</select>
<br>
<label for="desktop">Desktop: </label>
<select id="desktop">
<option value="system">System&apos;s</option>
<option value="tf_user">TF_User\Desktop</option>
<option value="documents" selected>PAF\Documents\Desktop</option>
</select>
<br>
<label for="downloads">Downloads: </label>
<select id="downloads">
<option value="system">System&apos;s</option>
<option value="tf_user">TF_User\Downloads</option>
<option value="documents" selected>PAF\Documents\Downloads</option>
</select>
<br>
<input type="checkbox" id="system_documents">
<label for="system_documents">Use System&apos;s Documents Folder</label>
<br>
<input type="checkbox" id="system_pictures">
<label for="system_pictures">Use System&apos;s Pictures Folder</label>
<br>
<input type="checkbox" id="system_videos">
<label for="system_videos">Use System&apos;s Videos Folder</label>
<br>
<input type="checkbox" id="system_music">
<label for="system_music">Use System&apos;s Music Folder</label>
<br>
<input type="checkbox" id="system_config">
<label for="system_config">Use System&apos;s Config Folder</label>
<br>
<input type="checkbox" id="system_cache">
<label for="system_cache">Use System&apos;s Cache Folder</label>
<br>
<input type="checkbox" id="system_data">
<label for="system_data">Use System&apos;s Data Folder</label>
<br>
<input type="checkbox" id="system_state">
<label for="system_state">Use System&apos;s State Folder</label>
<br>
<input type="checkbox" id="system_temp" checked>
<label for="system_temp">Use System&apos;s Temp Folder</label>
</fieldset>
<button id="saveBtn">Save</button>
<script>
(function(){
saveBtn.onclick = ()=>{
const dict = {
portable_type: "PortableApps.com",
portable_data: {
user: user.value,
desktop: desktop.value,
downloads: downloads.value,
system_documents: system_documents.checked,
system_pictures: system_pictures.checked,
system_videos: system_videos.checked,
system_music: system_music.checked,
system_config: system_config.checked,
system_cache: system_cache.checked,
system_data: system_data.checked,
system_state: system_state.checked,
system_temp: system_temp.checked
}
};
const json = JSON.stringify(dict,null,'\t');
const a = document.createElement('a');
a.href = `data:text/json;charset=utf-8,${encodeURIComponent(json)}`;
a.download="portable.json";
a.click();
};
})();
</script>
</body>
</html>

View File

@@ -0,0 +1,157 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TessesFramework portable.json creator</title>
</head>
<body>
<h1>TessesFramework portable.json creator</h1>
Want PortableApps.com click <a href="../portableapps/">here</a>
<br>system: don&apos;t make this folder portable, default: the default value (not portable if TF_User directory is &quot;system&quot;, otherwise it&apos;s a subdirectory in the TF_User directory), anything else is relative to executable directory (for all of these)
<br>Please use &quot;/&quot; and not &quot;\&quot; even if on Windows
<fieldset>
<legend>Configuration</legend>
<label for="user">TF_User: </label>
<datalist id="user_datalist">
<option>system</option>
<option>../TF_User</option>
</datalist>
<input type="text" id="user" value="../TF_User" list="user_datalist">
<br>
<label for="documents">Documents: </label>
<datalist id="documents_datalist">
<option>system</option>
<option>default</option>
<option>../TF_User/Documents</option>
</datalist>
<input type="text" id="documents" value="default" list="documents_datalist">
<br>
<label for="downloads">Downloads: </label>
<datalist id="downloads_datalist">
<option>system</option>
<option>default</option>
<option>../TF_User/Downloads</option>
</datalist>
<input type="text" id="downloads" value="default" list="downloads_datalist">
<br>
<label for="desktop">Desktop: </label>
<datalist id="desktop_datalist">
<option>system</option>
<option>default</option>
<option>../TF_User/Desktop</option>
</datalist>
<input type="text" id="desktop" value="default" list="desktop_datalist">
<br>
<label for="pictures">Pictures: </label>
<datalist id="pictures_datalist">
<option>system</option>
<option>default</option>
<option>../TF_User/Pictures</option>
</datalist>
<input type="text" id="pictures" value="default" list="pictures_datalist">
<br>
<label for="videos">Videos: </label>
<datalist id="videos_datalist">
<option>system</option>
<option>default</option>
<option>../TF_User/Videos</option>
</datalist>
<input type="text" id="videos" value="default" list="videos_datalist">
<br>
<label for="music">Music: </label>
<datalist id="music_datalist">
<option>system</option>
<option>default</option>
<option>../TF_User/Music</option>
</datalist>
<input type="text" id="music" value="default" list="music_datalist">
<br>
<label for="config">Config: </label>
<datalist id="config_datalist">
<option>system</option>
<option>default</option>
<option>../TF_User/Config</option>
</datalist>
<input type="text" id="config" value="default" list="config_datalist">
<br>
<label for="cache">Cache: </label>
<datalist id="cache_datalist">
<option>system</option>
<option>default</option>
<option>../TF_User/Cache</option>
</datalist>
<input type="text" id="cache" value="default" list="cache_datalist">
<br>
<label for="data">Data: </label>
<datalist id="data_datalist">
<option>system</option>
<option>default</option>
<option>../TF_User/Data</option>
</datalist>
<input type="text" id="data" value="default" list="data_datalist">
<br>
<label for="state">State: </label>
<datalist id="state_datalist">
<option>system</option>
<option>default</option>
<option>../TF_User/State</option>
</datalist>
<input type="text" id="state" value="default" list="state_datalist">
<br>
<label for="temp">Temp: </label>
<datalist id="temp_datalist">
<option>system</option>
<option>default</option>
<option>../TF_User/Temp</option>
</datalist>
<input type="text" id="temp" value="system" list="temp_datalist">
</fieldset>
<button id="saveBtn">Save</button>
<script>
(function(){
saveBtn.onclick = ()=>{
const dict = {
portable_type: "relative",
portable_data: {
user: user.value,
documents: documents.value,
downloads: downloads.value,
desktop: desktop.value,
pictures: pictures.value,
videos: videos.value,
music: music.value,
config: config.value,
cache: cache.value,
data: data.value,
state: state.value,
temp: temp.value
}
};
const json = JSON.stringify(dict,null,'\t');
const a = document.createElement('a');
a.href = `data:text/json;charset=utf-8,${encodeURIComponent(json)}`;
a.download="portable.json";
a.click();
};
})();
</script>
</body>
</html>

View File

@@ -210,7 +210,13 @@ namespace Tesses::Framework::Filesystem {
} }
TempFS::~TempFS() TempFS::~TempFS()
{ {
Close(); VFSPath p;
p.relative = false;
p.path.push_back(this->tmp_str);
this->vfs = nullptr;
if(this->deleteOnDestroy && this->parent->DirectoryExists(p))
this->parent->DeleteDirectoryRecurse(p);
} }
} }

View File

@@ -22,15 +22,23 @@ namespace Tesses::Framework::Platform::Environment
#else #else
const char EnvPathSeperator=':'; const char EnvPathSeperator=':';
#endif #endif
PortableAppConfig portable_config;
namespace SpecialFolders namespace SpecialFolders
{ {
VFSPath GetTemp() VFSPath GetTemp()
{ {
if(portable_config.temp)
return *portable_config.temp;
return std::filesystem::temp_directory_path().string(); return std::filesystem::temp_directory_path().string();
} }
VFSPath GetHomeFolder() VFSPath GetHomeFolder()
{ {
if(portable_config.user)
return *portable_config.user;
#if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE) #if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE)
return sago::getHomeDir(); return sago::getHomeDir();
#elif defined(__EMSCRIPTEN__) #elif defined(__EMSCRIPTEN__)
@@ -43,6 +51,9 @@ namespace Tesses::Framework::Platform::Environment
} }
VFSPath GetDownloads() VFSPath GetDownloads()
{ {
if(portable_config.downloads)
return *portable_config.downloads;
#if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE) #if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE)
return sago::getDownloadFolder(); return sago::getDownloadFolder();
#elif defined(__ANDROID__) #elif defined(__ANDROID__)
@@ -53,6 +64,9 @@ namespace Tesses::Framework::Platform::Environment
} }
VFSPath GetMusic() VFSPath GetMusic()
{ {
if(portable_config.music)
return *portable_config.music;
#if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE) #if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE)
return sago::getMusicFolder(); return sago::getMusicFolder();
#elif defined(__ANDROID__) #elif defined(__ANDROID__)
@@ -63,6 +77,9 @@ namespace Tesses::Framework::Platform::Environment
} }
VFSPath GetPictures() VFSPath GetPictures()
{ {
if(portable_config.pictures)
return *portable_config.pictures;
#if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE) #if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE)
return sago::getPicturesFolder(); return sago::getPicturesFolder();
#elif defined(__ANDROID__) #elif defined(__ANDROID__)
@@ -73,6 +90,8 @@ namespace Tesses::Framework::Platform::Environment
} }
VFSPath GetVideos() VFSPath GetVideos()
{ {
if(portable_config.videos)
return *portable_config.videos;
#if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE) #if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE)
return sago::getVideoFolder(); return sago::getVideoFolder();
#elif defined(__ANDROID__) #elif defined(__ANDROID__)
@@ -83,6 +102,9 @@ namespace Tesses::Framework::Platform::Environment
} }
VFSPath GetDocuments() VFSPath GetDocuments()
{ {
if(portable_config.documents)
return *portable_config.documents;
#if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE) #if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE)
return sago::getDocumentsFolder(); return sago::getDocumentsFolder();
#elif defined(__ANDROID__) #elif defined(__ANDROID__)
@@ -93,6 +115,9 @@ namespace Tesses::Framework::Platform::Environment
} }
VFSPath GetConfig() VFSPath GetConfig()
{ {
if(portable_config.config)
return *portable_config.config;
#if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE) #if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE)
return sago::getConfigHome(); return sago::getConfigHome();
#else #else
@@ -101,6 +126,8 @@ namespace Tesses::Framework::Platform::Environment
} }
VFSPath GetDesktop() VFSPath GetDesktop()
{ {
if(portable_config.desktop)
return *portable_config.desktop;
#if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE) #if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE)
return sago::getDesktopFolder(); return sago::getDesktopFolder();
#else #else
@@ -109,6 +136,9 @@ namespace Tesses::Framework::Platform::Environment
} }
VFSPath GetState() VFSPath GetState()
{ {
if(portable_config.state)
return *portable_config.state;
#if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE) #if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE)
return sago::getStateDir(); return sago::getStateDir();
#else #else
@@ -117,6 +147,9 @@ namespace Tesses::Framework::Platform::Environment
} }
VFSPath GetCache() VFSPath GetCache()
{ {
if(portable_config.cache)
return *portable_config.cache;
#if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE) #if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE)
return sago::getCacheDir(); return sago::getCacheDir();
#else #else
@@ -125,6 +158,9 @@ namespace Tesses::Framework::Platform::Environment
} }
VFSPath GetData() VFSPath GetData()
{ {
if(portable_config.data)
return *portable_config.data;
#if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE) #if defined(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) && !defined(SAGO_DISABLE)
return sago::getDataHome(); return sago::getDataHome();
#else #else

View File

@@ -104,7 +104,12 @@ namespace Tesses::Framework::Streams
} }
FileStream::~FileStream() FileStream::~FileStream()
{ {
Close(); if(!f) return;
if(this->owns)
{
fclose(this->f);
f=NULL;
}
} }
void FileStream::Close() void FileStream::Close()
{ {

View File

@@ -538,7 +538,10 @@ namespace Tesses::Framework::Streams {
TcpServer::~TcpServer() TcpServer::~TcpServer()
{ {
if(this->valid && this->owns) if(this->valid && this->owns)
Close(); {
NETWORK_CLOSE(this->sock);
}
this->valid=false;
} }
void TcpServer::Close() void TcpServer::Close()
{ {
@@ -818,7 +821,9 @@ namespace Tesses::Framework::Streams {
} }
NetworkStream::~NetworkStream() NetworkStream::~NetworkStream()
{ {
Close(); if(this->owns && this->success)
NETWORK_CLOSE(this->sock);
this->success=0;
} }
void NetworkStream::SetNoDelay(bool noDelay) void NetworkStream::SetNoDelay(bool noDelay)
{ {
@@ -945,5 +950,8 @@ uint16_t TcpServer::GetPort()
{ {
return 0; return 0;
} }
bool NetworkStream::DataAvailable(int to){
return false;
}
} }
#endif #endif

View File

@@ -126,7 +126,13 @@ namespace Tesses::Framework::Streams {
} }
PtyStream::~PtyStream() PtyStream::~PtyStream()
{ {
Close(); if(this->eos) return;
this->eos=true;
#if !defined(GEKKO) && !defined(__APPLE__) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) && defined(TESSESFRAMEWORK_ENABLE_PROCESS)
close(this->socket);
kill((pid_t)this->pid,SIGHUP);
#endif
} }
void PtyStream::Close() void PtyStream::Close()
{ {

View File

@@ -2,6 +2,9 @@
#include "TessesFramework/Streams/NetworkStream.hpp" #include "TessesFramework/Streams/NetworkStream.hpp"
#include "TessesFramework/Lazy.hpp" #include "TessesFramework/Lazy.hpp"
#include "TessesFramework/Filesystem/LocalFS.hpp" #include "TessesFramework/Filesystem/LocalFS.hpp"
#include "TessesFramework/Platform/Environment.hpp"
#include "TessesFramework/Filesystem/FSHelpers.hpp"
#include "TessesFramework/Serialization/Json.hpp"
#include <atomic> #include <atomic>
#include <csignal> #include <csignal>
#include <iostream> #include <iostream>
@@ -329,10 +332,390 @@ if (iResult != 0) {
} }
std::optional<std::string> _argv0=std::nullopt; std::optional<std::string> _argv0=std::nullopt;
void TF_AllowPortable(std::string argv0) void TF_AllowPortable(std::string argv0)
{ {
using namespace Tesses::Framework::Serialization::Json;
using namespace Tesses::Framework::Platform::Environment;
using namespace Tesses::Framework::Filesystem;
_argv0 = argv0; _argv0 = argv0;
VFSPath path(argv0);
auto realPath=path.MakeAbsolute();
auto dir = realPath.GetParent();
auto portable=dir / "portable.json";
if(LocalFS->FileExists(portable))
{
std::string portable_str;
Helpers::ReadAllText(LocalFS,portable, portable_str);
auto jsonObj=Json::Decode(portable_str);
JObject dict;
JObject dict2;
if(TryGetJToken(jsonObj,dict) && dict.TryGetValueAsType("portable_data",dict2))
{
if(dict.TryGetValueAsType("portable_type", portable_str))
{
if(portable_str == "PortableApps.com")
{
//do the special stuffs for PortableApps.com based apps
auto paf_documents = GetVariable("PortableApps.comDocuments");
auto paf_music = GetVariable("PortableApps.comMusic");
auto paf_pictures = GetVariable("PortableApps.comPictures");
auto paf_videos = GetVariable("PortableApps.comVideos");
auto paf_data = GetVariable("PAL:DataDir");
bool bV=false;
if(!dict2.TryGetValueAsType("system_documents",bV) || !bV)
{
if(paf_documents)
{
portable_config.documents = LocalFS->SystemToVFSPath(*paf_documents);
}
}
if(!dict2.TryGetValueAsType("system_pictures",bV) || !bV)
{
if(paf_pictures)
{
portable_config.pictures = LocalFS->SystemToVFSPath(*paf_pictures);
}
}
if(!dict2.TryGetValueAsType("system_videos",bV) || !bV)
{
if(paf_videos)
{
portable_config.videos = LocalFS->SystemToVFSPath(*paf_videos);
}
}
if(!dict2.TryGetValueAsType("system_music",bV) || !bV)
{
if(paf_music)
{
portable_config.music = LocalFS->SystemToVFSPath(*paf_music);
}
}
if(dict2.TryGetValueAsType("user",portable_str))
{
if(portable_str == "app")
{
if(paf_data)
portable_config.user = LocalFS->SystemToVFSPath(*paf_data) / "TF_User";
}
else if(portable_str == "documents")
{
if(paf_documents)
portable_config.user = LocalFS->SystemToVFSPath(*paf_documents) / "TF_User";
}
}
if(dict2.TryGetValueAsType("desktop",portable_str))
{
if(portable_str == "tf_user")
{
if(portable_config.user)
portable_config.desktop = *(portable_config.user) / "Desktop";
}
else if(portable_str == "documents")
{
if(paf_documents)
portable_config.desktop = LocalFS->SystemToVFSPath(*paf_documents) / "Desktop";
}
}
if(dict2.TryGetValueAsType("downloads",portable_str))
{
if(portable_str == "tf_user")
{
if(portable_config.user)
portable_config.downloads = *(portable_config.user) / "Downloads";
}
else if(portable_str == "documents")
{
if(paf_documents)
portable_config.downloads = LocalFS->SystemToVFSPath(*paf_documents) / "Downloads";
}
}
if(!dict2.TryGetValueAsType("system_config",bV) || !bV)
{
if(portable_config.user)
portable_config.config = *(portable_config.user) / "Config";
}
if(!dict2.TryGetValueAsType("system_cache",bV) || !bV)
{
if(portable_config.user)
portable_config.cache = *(portable_config.user) / "Cache";
}
if(!dict2.TryGetValueAsType("system_data",bV) || !bV)
{
if(portable_config.user)
portable_config.data = *(portable_config.user) / "Data";
}
if(!dict2.TryGetValueAsType("system_state",bV) || !bV)
{
if(portable_config.user)
portable_config.state = *(portable_config.user) / "State";
}
if(!dict2.TryGetValueAsType("system_temp",bV) || !bV)
{
if(portable_config.user)
portable_config.temp = *(portable_config.user) / "Temp";
}
}
else if(portable_str == "relative")
{
if(dict2.TryGetValueAsType("user",portable_str))
{
if(portable_str != "system")
{
auto userDir = dir / portable_str;
portable_config.user = userDir.CollapseRelativeParents();
}
}
if(dict2.TryGetValueAsType("documents", portable_str))
{
if(portable_str != "system")
{
if(portable_str == "default")
{
if(portable_config.user)
{
portable_config.documents = *(portable_config.user) / "Documents";
}
}
else
{
auto userDir = dir / portable_str;
portable_config.documents = userDir.CollapseRelativeParents();
}
}
}
if(dict2.TryGetValueAsType("downloads", portable_str))
{
if(portable_str != "system")
{
if(portable_str == "default")
{
if(portable_config.user)
{
portable_config.downloads = *(portable_config.user) / "Downloads";
}
}
else
{
auto userDir = dir / portable_str;
portable_config.downloads = userDir.CollapseRelativeParents();
}
}
}
if(dict2.TryGetValueAsType("desktop", portable_str))
{
if(portable_str != "system")
{
if(portable_str == "default")
{
if(portable_config.user)
{
portable_config.desktop = *(portable_config.user) / "Desktop";
}
}
else
{
auto userDir = dir / portable_str;
portable_config.desktop = userDir.CollapseRelativeParents();
}
}
}
if(dict2.TryGetValueAsType("pictures", portable_str))
{
if(portable_str != "system")
{
if(portable_str == "default")
{
if(portable_config.user)
{
portable_config.pictures = *(portable_config.user) / "Pictures";
}
}
else
{
auto userDir = dir / portable_str;
portable_config.pictures = userDir.CollapseRelativeParents();
}
}
}
if(dict2.TryGetValueAsType("videos", portable_str))
{
if(portable_str != "system")
{
if(portable_str == "default")
{
if(portable_config.user)
{
portable_config.videos = *(portable_config.user) / "Videos";
}
}
else
{
auto userDir = dir / portable_str;
portable_config.videos = userDir.CollapseRelativeParents();
}
}
}
if(dict2.TryGetValueAsType("music", portable_str))
{
if(portable_str != "system")
{
if(portable_str == "default")
{
if(portable_config.user)
{
portable_config.music = *(portable_config.user) / "Music";
}
}
else
{
auto userDir = dir / portable_str;
portable_config.music = userDir.CollapseRelativeParents();
}
}
}
if(dict2.TryGetValueAsType("config", portable_str))
{
if(portable_str != "system")
{
if(portable_str == "default")
{
if(portable_config.user)
{
portable_config.config = *(portable_config.user) / "Config";
}
}
else
{
auto userDir = dir / portable_str;
portable_config.config = userDir.CollapseRelativeParents();
}
}
}
if(dict2.TryGetValueAsType("cache", portable_str))
{
if(portable_str != "system")
{
if(portable_str == "default")
{
if(portable_config.user)
{
portable_config.cache = *(portable_config.user) / "Cache";
}
}
else
{
auto userDir = dir / portable_str;
portable_config.cache = userDir.CollapseRelativeParents();
}
}
}
if(dict2.TryGetValueAsType("data", portable_str))
{
if(portable_str != "system")
{
if(portable_str == "default")
{
if(portable_config.user)
{
portable_config.data = *(portable_config.user) / "Data";
}
}
else
{
auto userDir = dir / portable_str;
portable_config.data = userDir.CollapseRelativeParents();
}
}
}
if(dict2.TryGetValueAsType("state", portable_str))
{
if(portable_str != "system")
{
if(portable_str == "default")
{
if(portable_config.user)
{
portable_config.state = *(portable_config.user) / "State";
}
}
else
{
auto userDir = dir / portable_str;
portable_config.state = userDir.CollapseRelativeParents();
}
}
}
if(dict2.TryGetValueAsType("temp", portable_str))
{
if(portable_str != "system")
{
if(portable_str == "default")
{
if(portable_config.user)
{
portable_config.temp = *(portable_config.user) / "Temp";
}
}
else
{
auto userDir = dir / portable_str;
portable_config.temp = userDir.CollapseRelativeParents();
}
}
}
}
}
}
}
} }
std::optional<std::string> TF_GetCommandName() std::optional<std::string> TF_GetCommandName()