Compare commits
2 Commits
37fd44fd78
...
v0.0.4
| Author | SHA1 | Date | |
|---|---|---|---|
| 28eff630c6 | |||
| f23a3880d4 |
@@ -7,7 +7,7 @@ echo " url \"https://git.tesses.org/tesses50/crosslang/archive/$VERSION.tar.gz\
|
||||
echo " sha256 \"$HASH\"" >> "Formula/crosslang.rb"
|
||||
echo " license \"GPLv3\"" >> "Formula/crosslang.rb"
|
||||
echo " depends_on \"cmake\" => :build" >> "Formula/crosslang.rb"
|
||||
echo " depends_on \"tessesframework\"" >> "Formula/crosslang.rb"
|
||||
echo " depends_on \"tesses50/tesses-tap/tessesframework\"" >> "Formula/crosslang.rb"
|
||||
echo " def install" >> "Formula/crosslang.rb"
|
||||
echo " system \"cmake\", \"-S\", \".\", \"-B\", \"build\", \"-DCROSSLANG_FETCHCONTENT=OFF\", *std_cmake_args" >> "Formula/crosslang.rb"
|
||||
echo " system \"cmake\", \"--build\", \"build\"" >> "Formula/crosslang.rb"
|
||||
|
||||
@@ -49,7 +49,6 @@ src/types/streamheapobject.cpp
|
||||
src/types/class.cpp
|
||||
src/types/classenvironment.cpp
|
||||
src/types/random.cpp
|
||||
src/types/relativefs.cpp
|
||||
src/vm/filereader.cpp
|
||||
src/vm/gc.cpp
|
||||
src/vm/gclist.cpp
|
||||
|
||||
@@ -41,51 +41,6 @@ namespace Tesses::CrossLang {
|
||||
constexpr std::string_view VMName = "CrossLangVM";
|
||||
constexpr std::string_view VMHowToGet = "https://crosslang.tesseslanguage.com/";
|
||||
|
||||
class RelativeFilesystem : public Tesses::Framework::Filesystem::VFS
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs;
|
||||
Tesses::Framework::Filesystem::VFSPath path;
|
||||
Tesses::Framework::Threading::Mutex mtx;
|
||||
|
||||
public:
|
||||
RelativeFilesystem(std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs, Tesses::Framework::Filesystem::VFSPath working);
|
||||
std::shared_ptr<Tesses::Framework::Streams::Stream> OpenFile(Tesses::Framework::Filesystem::VFSPath path, std::string mode);
|
||||
|
||||
void CreateDirectory(Tesses::Framework::Filesystem::VFSPath path);
|
||||
void DeleteDirectory(Tesses::Framework::Filesystem::VFSPath path);
|
||||
|
||||
|
||||
void DeleteFile(Tesses::Framework::Filesystem::VFSPath path);
|
||||
void CreateSymlink(Tesses::Framework::Filesystem::VFSPath existingFile, Tesses::Framework::Filesystem::VFSPath symlinkFile);
|
||||
Tesses::Framework::Filesystem::VFSPathEnumerator EnumeratePaths(Tesses::Framework::Filesystem::VFSPath path);
|
||||
void CreateHardlink(Tesses::Framework::Filesystem::VFSPath existingFile, Tesses::Framework::Filesystem::VFSPath newName);
|
||||
|
||||
void MoveFile(Tesses::Framework::Filesystem::VFSPath src, Tesses::Framework::Filesystem::VFSPath dest);
|
||||
|
||||
void MoveDirectory(Tesses::Framework::Filesystem::VFSPath src, Tesses::Framework::Filesystem::VFSPath dest);
|
||||
Tesses::Framework::Filesystem::VFSPath ReadLink(Tesses::Framework::Filesystem::VFSPath path);
|
||||
std::string VFSPathToSystem(Tesses::Framework::Filesystem::VFSPath path);
|
||||
Tesses::Framework::Filesystem::VFSPath SystemToVFSPath(std::string path);
|
||||
|
||||
void SetDate(Tesses::Framework::Filesystem::VFSPath path, Tesses::Framework::Date::DateTime lastWrite, Tesses::Framework::Date::DateTime lastAccess);
|
||||
bool Stat(Tesses::Framework::Filesystem::VFSPath path, Tesses::Framework::Filesystem::StatData& stat);
|
||||
bool StatVFS(Tesses::Framework::Filesystem::VFSPath path, Tesses::Framework::Filesystem::StatVFSData& vfsData);
|
||||
|
||||
void Chmod(Tesses::Framework::Filesystem::VFSPath path, uint32_t mode);
|
||||
void Chown(Tesses::Framework::Filesystem::VFSPath path, uint32_t uid, uint32_t gid);
|
||||
|
||||
void Lock(Tesses::Framework::Filesystem::VFSPath path);
|
||||
void Unlock(Tesses::Framework::Filesystem::VFSPath path);
|
||||
|
||||
Tesses::Framework::Filesystem::FIFOCreationResult CreateFIFO(Tesses::Framework::Filesystem::VFSPath path, uint32_t mod);
|
||||
Tesses::Framework::Filesystem::VFSPath GetWorking();
|
||||
void SetWorking(Tesses::Framework::Filesystem::VFSPath working);
|
||||
std::shared_ptr<Tesses::Framework::Filesystem::VFS> GetVFS();
|
||||
protected:
|
||||
std::shared_ptr<Tesses::Framework::Filesystem::FSWatcher> CreateWatcher(std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs, Tesses::Framework::Filesystem::VFSPath path);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Escape a crosslang string (for generating source code)
|
||||
@@ -1822,7 +1777,7 @@ class GC : public std::enable_shared_from_this<GC> {
|
||||
public:
|
||||
EnvironmentPermissions();
|
||||
Tesses::Framework::Filesystem::VFSPath sqliteOffsetPath;
|
||||
std::shared_ptr<RelativeFilesystem> localfs;
|
||||
std::shared_ptr<Tesses::Framework::Filesystem::RelativeFilesystem> localfs;
|
||||
bool canRegisterEverything;
|
||||
bool canRegisterConsole;
|
||||
bool canRegisterIO;
|
||||
@@ -1886,10 +1841,10 @@ class GC : public std::enable_shared_from_this<GC> {
|
||||
static void RegisterHelpers(std::shared_ptr<GC> gc, TRootEnvironment* env);
|
||||
static void RegisterUuid(std::shared_ptr<GC> gc, TRootEnvironment* env);
|
||||
public:
|
||||
static void RegisterStd(std::shared_ptr<GC> gc, TRootEnvironment* env, std::shared_ptr<RelativeFilesystem> localfs);
|
||||
static void RegisterStd(std::shared_ptr<GC> gc, TRootEnvironment* env, std::shared_ptr<Tesses::Framework::Filesystem::RelativeFilesystem> localfs);
|
||||
static void RegisterStd(std::shared_ptr<GC> gc, TRootEnvironment* env);
|
||||
static void RegisterConsole(std::shared_ptr<GC> gc,TRootEnvironment* env);
|
||||
static void RegisterIO(std::shared_ptr<GC> gc,TRootEnvironment* env, std::shared_ptr<RelativeFilesystem> local);
|
||||
static void RegisterIO(std::shared_ptr<GC> gc,TRootEnvironment* env, std::shared_ptr<Tesses::Framework::Filesystem::RelativeFilesystem> local);
|
||||
static void RegisterIO(std::shared_ptr<GC> gc,TRootEnvironment* env, bool enableLocalFS=true);
|
||||
static void RegisterNet(std::shared_ptr<GC> gc, TRootEnvironment* env);
|
||||
static void RegisterSqlite(std::shared_ptr<GC> gc,TRootEnvironment* env);
|
||||
|
||||
@@ -264,14 +264,14 @@ namespace Tesses::CrossLang
|
||||
{
|
||||
if(enable)
|
||||
{
|
||||
RegisterIO(gc,env,std::make_shared<RelativeFilesystem>(Tesses::Framework::Filesystem::LocalFS, Tesses::Framework::Filesystem::VFSPath::GetAbsoluteCurrentDirectory()));
|
||||
RegisterIO(gc,env,std::make_shared<Tesses::Framework::Filesystem::RelativeFilesystem>(Tesses::Framework::Filesystem::LocalFS, Tesses::Framework::Filesystem::VFSPath::GetAbsoluteCurrentDirectory()));
|
||||
}
|
||||
else
|
||||
{
|
||||
RegisterIO(gc,env,nullptr);
|
||||
}
|
||||
}
|
||||
void TStd::RegisterIO(std::shared_ptr<GC> gc,TRootEnvironment* env,std::shared_ptr<RelativeFilesystem> fs)
|
||||
void TStd::RegisterIO(std::shared_ptr<GC> gc,TRootEnvironment* env,std::shared_ptr<Tesses::Framework::Filesystem::RelativeFilesystem> fs)
|
||||
{
|
||||
|
||||
env->permissions.canRegisterIO=true;
|
||||
@@ -332,8 +332,14 @@ namespace Tesses::CrossLang
|
||||
Tesses::Framework::Filesystem::VFSPath path;
|
||||
if(GetArgumentAsPath(args,0,path))
|
||||
{
|
||||
if(path.relative)
|
||||
{
|
||||
fs->SetWorking(path.MakeAbsolute(fs->GetWorking()));
|
||||
}
|
||||
else {
|
||||
fs->SetWorking(path);
|
||||
}
|
||||
}
|
||||
return path;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -864,20 +864,12 @@ namespace Tesses::CrossLang
|
||||
auto vfs = std::get<std::shared_ptr<Tesses::Framework::Filesystem::VFS>>(_obj);
|
||||
if(vfs != nullptr)
|
||||
{
|
||||
auto rfs = std::dynamic_pointer_cast<RelativeFilesystem>(vfs);
|
||||
auto rfs = std::dynamic_pointer_cast<Tesses::Framework::Filesystem::RelativeFilesystem>(vfs);
|
||||
auto localVFS = std::dynamic_pointer_cast<Tesses::Framework::Filesystem::LocalFilesystem>(vfs);
|
||||
auto mountableVFS = std::dynamic_pointer_cast<Tesses::Framework::Filesystem::MountableFilesystem>(vfs);
|
||||
auto subFS = std::dynamic_pointer_cast<Tesses::Framework::Filesystem::SubdirFilesystem>(vfs);
|
||||
auto tempFS = std::dynamic_pointer_cast<Tesses::Framework::Filesystem::TempFS>(vfs);
|
||||
if(rfs)
|
||||
{
|
||||
auto fs=rfs->GetVFS();
|
||||
if(fs)
|
||||
{
|
||||
return GetObjectTypeString(fs);
|
||||
}
|
||||
return "RelativeFilesystem";
|
||||
}
|
||||
if(rfs) return "RelativeFilesystem";
|
||||
if(localVFS != nullptr) return "LocalFilesystem";
|
||||
if(subFS != nullptr) return "SubdirFilesystem";
|
||||
if(mountableVFS != nullptr) return "MountableFilesystem";
|
||||
@@ -1301,6 +1293,17 @@ namespace Tesses::CrossLang
|
||||
return Tesses::Framework::TF_Timer(empty, 1000L, false);
|
||||
}
|
||||
|
||||
static TObject New_RelativeFilesystem(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs;
|
||||
Tesses::Framework::Filesystem::VFSPath path;
|
||||
if(GetArgument(args,0,vfs) && GetArgumentAsPath(args,1,path) && !path.relative)
|
||||
{
|
||||
return std::make_shared<Tesses::Framework::Filesystem::RelativeFilesystem>(vfs,path);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void TStd::RegisterRoot(std::shared_ptr<GC> gc, TRootEnvironment* env)
|
||||
{
|
||||
GCList ls(gc);
|
||||
@@ -1363,6 +1366,7 @@ namespace Tesses::CrossLang
|
||||
newTypes->DeclareFunction(gc, "SubdirFilesystem","Create a subdir filesystem",{"fs","subdir"}, New_SubdirFilesystem);
|
||||
newTypes->DeclareFunction(gc, "MemoryStream","Create a memory stream",{"writable"}, New_MemoryStream);
|
||||
newTypes->DeclareFunction(gc, "Filesystem","Create filesystem", {"fs"},New_Filesystem);
|
||||
newTypes->DeclareFunction(gc, "RelativeFilesystem", "Create relativefs",{"parent", "absoluteDir"}, New_RelativeFilesystem);
|
||||
newTypes->DeclareFunction(gc, "TempFS","Create a temp directory",{"",""}, New_TempFS);
|
||||
newTypes->DeclareFunction(gc, "Timer", "Create a timer",{"$cb","$interval","$enabled"}, New_Timer);
|
||||
newTypes->DeclareFunction(gc, "Stream","Create stream", {"strm"},New_Stream);
|
||||
@@ -1519,14 +1523,15 @@ namespace Tesses::CrossLang
|
||||
}
|
||||
void TStd::RegisterStd(std::shared_ptr<GC> gc, TRootEnvironment* env)
|
||||
{
|
||||
RegisterStd(gc, env, std::make_shared<RelativeFilesystem>(Tesses::Framework::Filesystem::LocalFS, Tesses::Framework::Filesystem::VFSPath::GetAbsoluteCurrentDirectory()));
|
||||
RegisterStd(gc, env, std::make_shared<Tesses::Framework::Filesystem::RelativeFilesystem>(Tesses::Framework::Filesystem::LocalFS, Tesses::Framework::Filesystem::VFSPath::GetAbsoluteCurrentDirectory()));
|
||||
}
|
||||
void TStd::RegisterStd(std::shared_ptr<GC> gc, TRootEnvironment* env,std::shared_ptr<RelativeFilesystem> localfs)
|
||||
void TStd::RegisterStd(std::shared_ptr<GC> gc, TRootEnvironment* env,std::shared_ptr<Tesses::Framework::Filesystem::RelativeFilesystem> localfs)
|
||||
{
|
||||
env->permissions.canRegisterEverything=true;
|
||||
RegisterEnv(gc, env);
|
||||
RegisterRoot(gc,env);
|
||||
RegisterPath(gc,env);
|
||||
|
||||
RegisterConsole(gc, env);
|
||||
RegisterIO(gc, env, localfs);
|
||||
RegisterNet(gc, env);
|
||||
|
||||
@@ -1,275 +0,0 @@
|
||||
#include "CrossLang.hpp"
|
||||
|
||||
namespace Tesses::CrossLang
|
||||
{
|
||||
RelativeFilesystem::RelativeFilesystem(std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs, Tesses::Framework::Filesystem::VFSPath working)
|
||||
{
|
||||
this->vfs = vfs;
|
||||
this->path = working;
|
||||
}
|
||||
std::shared_ptr<Tesses::Framework::Streams::Stream> RelativeFilesystem::OpenFile(Tesses::Framework::Filesystem::VFSPath path, std::string mode)
|
||||
{
|
||||
if(path.relative)
|
||||
{
|
||||
return this->vfs->OpenFile(path.MakeAbsolute(GetWorking()), mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
return this->vfs->OpenFile(path,mode);
|
||||
}
|
||||
}
|
||||
|
||||
void RelativeFilesystem::CreateDirectory(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
if(path.relative)
|
||||
{
|
||||
this->vfs->CreateDirectory(path.MakeAbsolute(GetWorking()));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->vfs->CreateDirectory(path);
|
||||
}
|
||||
}
|
||||
void RelativeFilesystem::DeleteDirectory(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
if(path.relative)
|
||||
{
|
||||
this->vfs->DeleteDirectory(path.MakeAbsolute(GetWorking()));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->vfs->DeleteDirectory(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RelativeFilesystem::DeleteFile(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
if(path.relative)
|
||||
{
|
||||
this->vfs->DeleteFile(path.MakeAbsolute(GetWorking()));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->vfs->DeleteFile(path);
|
||||
}
|
||||
}
|
||||
void RelativeFilesystem::CreateSymlink(Tesses::Framework::Filesystem::VFSPath existingFile, Tesses::Framework::Filesystem::VFSPath symlinkFile)
|
||||
{
|
||||
if(symlinkFile.relative)
|
||||
{
|
||||
this->vfs->CreateSymlink(existingFile,symlinkFile.MakeAbsolute(GetWorking()));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->vfs->CreateSymlink(existingFile, symlinkFile);
|
||||
}
|
||||
}
|
||||
Tesses::Framework::Filesystem::VFSPathEnumerator RelativeFilesystem::EnumeratePaths(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
if(path.relative)
|
||||
{
|
||||
return this->vfs->EnumeratePaths(path.MakeAbsolute(GetWorking()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return this->vfs->EnumeratePaths(path);
|
||||
}
|
||||
}
|
||||
void RelativeFilesystem::CreateHardlink(Tesses::Framework::Filesystem::VFSPath existingFile, Tesses::Framework::Filesystem::VFSPath newName)
|
||||
{
|
||||
auto working = GetWorking();
|
||||
if(existingFile.relative)
|
||||
{
|
||||
existingFile = existingFile.MakeAbsolute(working);
|
||||
existingFile = existingFile.CollapseRelativeParents();
|
||||
}
|
||||
|
||||
if(newName.relative)
|
||||
{
|
||||
newName = newName.MakeAbsolute(working);
|
||||
newName = newName.CollapseRelativeParents();
|
||||
}
|
||||
|
||||
this->vfs->CreateHardlink(existingFile, newName);
|
||||
}
|
||||
|
||||
void RelativeFilesystem::MoveFile(Tesses::Framework::Filesystem::VFSPath src, Tesses::Framework::Filesystem::VFSPath dest)
|
||||
{
|
||||
auto working = GetWorking();
|
||||
if(src.relative)
|
||||
{
|
||||
src = src.MakeAbsolute(working);
|
||||
src = src.CollapseRelativeParents();
|
||||
}
|
||||
|
||||
if(dest.relative)
|
||||
{
|
||||
dest = dest.MakeAbsolute(working);
|
||||
dest = dest.CollapseRelativeParents();
|
||||
}
|
||||
|
||||
this->vfs->MoveFile(src, dest);
|
||||
}
|
||||
|
||||
void RelativeFilesystem::MoveDirectory(Tesses::Framework::Filesystem::VFSPath src, Tesses::Framework::Filesystem::VFSPath dest)
|
||||
{
|
||||
|
||||
auto working = GetWorking();
|
||||
if(src.relative)
|
||||
{
|
||||
src = src.MakeAbsolute(working);
|
||||
src = src.CollapseRelativeParents();
|
||||
}
|
||||
|
||||
if(dest.relative)
|
||||
{
|
||||
dest = dest.MakeAbsolute(working);
|
||||
dest = dest.CollapseRelativeParents();
|
||||
}
|
||||
|
||||
this->vfs->MoveFile(src, dest);
|
||||
}
|
||||
Tesses::Framework::Filesystem::VFSPath RelativeFilesystem::ReadLink(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
if(path.relative)
|
||||
{
|
||||
return this->vfs->ReadLink(path.MakeAbsolute(GetWorking()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return this->vfs->ReadLink(path);
|
||||
}
|
||||
}
|
||||
std::string RelativeFilesystem::VFSPathToSystem(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
return this->vfs->VFSPathToSystem(path);
|
||||
}
|
||||
Tesses::Framework::Filesystem::VFSPath RelativeFilesystem::SystemToVFSPath(std::string path)
|
||||
{
|
||||
return this->vfs->SystemToVFSPath(path);
|
||||
}
|
||||
|
||||
void RelativeFilesystem::SetDate(Tesses::Framework::Filesystem::VFSPath path, Tesses::Framework::Date::DateTime lastWrite, Tesses::Framework::Date::DateTime lastAccess)
|
||||
{
|
||||
if(path.relative)
|
||||
{
|
||||
this->vfs->SetDate(path.MakeAbsolute(GetWorking()), lastWrite,lastAccess);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->vfs->SetDate(path,lastWrite,lastAccess);
|
||||
}
|
||||
}
|
||||
bool RelativeFilesystem::Stat(Tesses::Framework::Filesystem::VFSPath path, Tesses::Framework::Filesystem::StatData& stat)
|
||||
{
|
||||
if(path.relative)
|
||||
{
|
||||
return this->vfs->Stat(path.MakeAbsolute(GetWorking()), stat);
|
||||
}
|
||||
else
|
||||
{
|
||||
return this->vfs->Stat(path,stat);
|
||||
}
|
||||
}
|
||||
bool RelativeFilesystem::StatVFS(Tesses::Framework::Filesystem::VFSPath path, Tesses::Framework::Filesystem::StatVFSData& vfsData)
|
||||
{
|
||||
if(path.relative)
|
||||
{
|
||||
return this->vfs->StatVFS(path.MakeAbsolute(GetWorking()), vfsData);
|
||||
}
|
||||
else
|
||||
{
|
||||
return this->vfs->StatVFS(path,vfsData);
|
||||
}
|
||||
}
|
||||
|
||||
void RelativeFilesystem::Chmod(Tesses::Framework::Filesystem::VFSPath path, uint32_t mode)
|
||||
{
|
||||
if(path.relative)
|
||||
{
|
||||
this->vfs->Chmod(path.MakeAbsolute(GetWorking()), mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->vfs->Chmod(path,mode);
|
||||
}
|
||||
}
|
||||
void RelativeFilesystem::Chown(Tesses::Framework::Filesystem::VFSPath path, uint32_t uid, uint32_t gid)
|
||||
{
|
||||
if(path.relative)
|
||||
{
|
||||
this->vfs->Chown(path.MakeAbsolute(GetWorking()), uid, gid);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->vfs->Chown(path,uid,gid);
|
||||
}
|
||||
}
|
||||
|
||||
void RelativeFilesystem::Lock(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
if(path.relative)
|
||||
{
|
||||
this->vfs->Lock(path.MakeAbsolute(GetWorking()));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->vfs->Lock(path);
|
||||
}
|
||||
}
|
||||
void RelativeFilesystem::Unlock(Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
if(path.relative)
|
||||
{
|
||||
this->vfs->Unlock(path.MakeAbsolute(GetWorking()));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->vfs->Unlock(path);
|
||||
}
|
||||
}
|
||||
|
||||
Tesses::Framework::Filesystem::FIFOCreationResult RelativeFilesystem::CreateFIFO(Tesses::Framework::Filesystem::VFSPath path, uint32_t mod)
|
||||
{
|
||||
if(path.relative)
|
||||
{
|
||||
return this->vfs->CreateFIFO(path.MakeAbsolute(GetWorking()), mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
return this->vfs->CreateFIFO(path, mod);
|
||||
}
|
||||
}
|
||||
Tesses::Framework::Filesystem::VFSPath RelativeFilesystem::GetWorking()
|
||||
{
|
||||
mtx.Lock();
|
||||
auto path = this->path;
|
||||
mtx.Unlock();
|
||||
return path;
|
||||
}
|
||||
void RelativeFilesystem::SetWorking(Tesses::Framework::Filesystem::VFSPath working)
|
||||
{
|
||||
mtx.Lock();
|
||||
this->path = working;
|
||||
mtx.Unlock();
|
||||
}
|
||||
std::shared_ptr<Tesses::Framework::Filesystem::VFS> RelativeFilesystem::GetVFS()
|
||||
{
|
||||
return this->vfs;
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<Tesses::Framework::Filesystem::FSWatcher> RelativeFilesystem::CreateWatcher(std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs, Tesses::Framework::Filesystem::VFSPath path)
|
||||
{
|
||||
if(path.relative)
|
||||
{
|
||||
return Tesses::Framework::Filesystem::FSWatcher::Create(vfs, path.MakeAbsolute(GetWorking()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Tesses::Framework::Filesystem::FSWatcher::Create(vfs,path);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1677,6 +1677,8 @@ namespace Tesses::CrossLang {
|
||||
auto myvfs = std::dynamic_pointer_cast<TObjectVFS>(vfs);
|
||||
|
||||
auto mountable = std::dynamic_pointer_cast<Tesses::Framework::Filesystem::MountableFilesystem>(vfs);
|
||||
|
||||
|
||||
if(myvfs != nullptr)
|
||||
{
|
||||
TDictionary* dict2;
|
||||
@@ -2284,10 +2286,36 @@ namespace Tesses::CrossLang {
|
||||
}
|
||||
if(key == "RegisterEverything")
|
||||
{
|
||||
if(myEnv->permissions.canRegisterEverything && myEnv->permissions.localfs)
|
||||
if(rootEnv->permissions.locked)
|
||||
{
|
||||
TStd::RegisterStd(gc, rootEnv, std::make_shared<RelativeFilesystem>(myEnv->permissions.localfs->GetVFS(),myEnv->permissions.localfs->GetWorking()));
|
||||
cse.back()->Push(gc,nullptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(myEnv->permissions.canRegisterEverything)
|
||||
{
|
||||
std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs;
|
||||
if(GetArgument(args,0, vfs))
|
||||
{
|
||||
|
||||
auto rfs = std::dynamic_pointer_cast<Tesses::Framework::Filesystem::RelativeFilesystem>(vfs);
|
||||
if(rfs)
|
||||
{
|
||||
TStd::RegisterStd(gc,rootEnv, rfs);
|
||||
cse.back()->Push(gc,nullptr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(myEnv->permissions.localfs)
|
||||
TStd::RegisterStd(gc, rootEnv, std::make_shared<Tesses::Framework::Filesystem::RelativeFilesystem>(myEnv->permissions.localfs->GetVFS(),myEnv->permissions.localfs->GetWorking()));
|
||||
else
|
||||
TStd::RegisterStd(gc, rootEnv, nullptr);
|
||||
|
||||
|
||||
|
||||
cse.back()->Push(gc,nullptr);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2308,7 +2336,7 @@ namespace Tesses::CrossLang {
|
||||
{
|
||||
if(myEnv->permissions.localfs)
|
||||
{
|
||||
TStd::RegisterIO(gc, rootEnv, std::make_shared<RelativeFilesystem>(myEnv->permissions.localfs->GetVFS(),myEnv->permissions.localfs->GetWorking()));
|
||||
TStd::RegisterIO(gc, rootEnv, std::make_shared<Tesses::Framework::Filesystem::RelativeFilesystem>(myEnv->permissions.localfs->GetVFS(),myEnv->permissions.localfs->GetWorking()));
|
||||
}
|
||||
else {
|
||||
TStd::RegisterIO(gc, rootEnv, nullptr);
|
||||
@@ -2388,6 +2416,8 @@ namespace Tesses::CrossLang {
|
||||
}
|
||||
if(key == "RegisterIO")
|
||||
{
|
||||
std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs;
|
||||
|
||||
bool r;
|
||||
if(GetArgument(args,0,r))
|
||||
{
|
||||
@@ -2395,13 +2425,21 @@ namespace Tesses::CrossLang {
|
||||
{
|
||||
if(myEnv->permissions.localfs)
|
||||
{
|
||||
TStd::RegisterIO(gc, rootEnv, std::make_shared<RelativeFilesystem>(myEnv->permissions.localfs->GetVFS(),myEnv->permissions.localfs->GetWorking()));
|
||||
TStd::RegisterIO(gc, rootEnv, std::make_shared<Tesses::Framework::Filesystem::RelativeFilesystem>(myEnv->permissions.localfs->GetVFS(),myEnv->permissions.localfs->GetWorking()));
|
||||
}
|
||||
else {
|
||||
TStd::RegisterIO(gc, rootEnv, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(GetArgument(args,0,vfs))
|
||||
{
|
||||
auto rfs = std::dynamic_pointer_cast<Tesses::Framework::Filesystem::RelativeFilesystem>(vfs);
|
||||
if(rfs && (myEnv->permissions.canRegisterEverything || myEnv->permissions.canRegisterIO) && !rootEnv->permissions.locked)
|
||||
{
|
||||
TStd::RegisterIO(gc, rootEnv, rfs);
|
||||
}
|
||||
}
|
||||
cse.back()->Push(gc,nullptr);
|
||||
return false;
|
||||
|
||||
|
||||
@@ -70,6 +70,29 @@ namespace Tesses::CrossLang {
|
||||
{
|
||||
auto vfs = std::get<std::shared_ptr<Tesses::Framework::Filesystem::VFS>>(instance);
|
||||
auto tmpFS=std::dynamic_pointer_cast<Tesses::Framework::Filesystem::TempFS>(vfs);
|
||||
auto relative = std::dynamic_pointer_cast<Tesses::Framework::Filesystem::RelativeFilesystem>(vfs);
|
||||
auto myFS = std::dynamic_pointer_cast<TObjectVFS>(vfs);
|
||||
if(relative)
|
||||
{
|
||||
if(key == "Working")
|
||||
{
|
||||
cse.back()->Push(gc, relative->GetWorking());
|
||||
return false;
|
||||
}
|
||||
if(key == "Filesystem")
|
||||
{
|
||||
cse.back()->Push(gc, relative->GetVFS());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(myFS)
|
||||
{
|
||||
if(key == "Inner")
|
||||
{
|
||||
cse.back()->Push(gc, myFS->obj);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(tmpFS)
|
||||
{
|
||||
if(key == "TempDirectoryName")
|
||||
|
||||
@@ -116,6 +116,34 @@ namespace Tesses::CrossLang {
|
||||
cse.back()->Push(gc,Undefined());
|
||||
return false;
|
||||
}
|
||||
if(std::holds_alternative<std::shared_ptr<Tesses::Framework::Filesystem::VFS>>(instance))
|
||||
{
|
||||
|
||||
auto vfs = std::get<std::shared_ptr<Tesses::Framework::Filesystem::VFS>>(instance);
|
||||
auto relative = std::dynamic_pointer_cast<Tesses::Framework::Filesystem::RelativeFilesystem>(vfs);
|
||||
|
||||
if(relative)
|
||||
{
|
||||
if(key == "Working")
|
||||
{
|
||||
Tesses::Framework::Filesystem::VFSPath path;
|
||||
if(GetObjectAsPath(value,path))
|
||||
{
|
||||
if(path.relative)
|
||||
{
|
||||
relative->SetWorking(path.MakeAbsolute(relative->GetWorking()));
|
||||
}
|
||||
else {
|
||||
relative->SetWorking(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cse.back()->Push(gc,Undefined());
|
||||
return false;
|
||||
}
|
||||
if(std::holds_alternative<std::shared_ptr<Tesses::Framework::Http::IHttpServer>>(instance))
|
||||
{
|
||||
auto svr = std::get<std::shared_ptr<Tesses::Framework::Http::IHttpServer>>(instance);
|
||||
|
||||
Reference in New Issue
Block a user