Allow the user to get and set current path
This commit is contained in:
@ -144,6 +144,18 @@ namespace Tesses::CrossLang
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static TObject FS_getCurrentPath(GCList& ls, std::vector<TObject> args)
|
||||||
|
{
|
||||||
|
return Tesses::Framework::Filesystem::VFSPath::GetAbsoluteCurrentDirectory();
|
||||||
|
}
|
||||||
|
static TObject FS_setCurrentPath(GCList& ls, std::vector<TObject> args)
|
||||||
|
{
|
||||||
|
Tesses::Framework::Filesystem::VFSPath path;
|
||||||
|
if(GetArgumentAsPath(args,0,path))
|
||||||
|
Tesses::Framework::Filesystem::VFSPath::SetAbsoluteCurrentDirectory(path);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void TStd::RegisterIO(GC* gc,TRootEnvironment* env,bool enableLocalFilesystem)
|
void TStd::RegisterIO(GC* gc,TRootEnvironment* env,bool enableLocalFilesystem)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -159,6 +171,8 @@ namespace Tesses::CrossLang
|
|||||||
|
|
||||||
dict->SetValue("Local", vfs);
|
dict->SetValue("Local", vfs);
|
||||||
dict->DeclareFunction(gc, "MakeFull", "Make absolute path from relative path",{"path"},FS_MakeFull);
|
dict->DeclareFunction(gc, "MakeFull", "Make absolute path from relative path",{"path"},FS_MakeFull);
|
||||||
|
dict->DeclareFunction(gc,"getCurrentPath","Get current path",{},FS_getCurrentPath);
|
||||||
|
dict->DeclareFunction(gc,"setCurrentPath","Set the current path",{"path"},FS_setCurrentPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
dict->DeclareFunction(gc, "ReadAllText","Read all text from file", {"fs","filename"},FS_ReadAllText);
|
dict->DeclareFunction(gc, "ReadAllText","Read all text from file", {"fs","filename"},FS_ReadAllText);
|
||||||
|
|||||||
@ -74,6 +74,7 @@ namespace Tesses::CrossLang
|
|||||||
|
|
||||||
gc->BarrierBegin();
|
gc->BarrierBegin();
|
||||||
dict->DeclareFunction(gc,"FromString","Create a Path from string",{"path"},Path_FromString);
|
dict->DeclareFunction(gc,"FromString","Create a Path from string",{"path"},Path_FromString);
|
||||||
|
|
||||||
dict->DeclareFunction(gc,"Create","Create a Path from parts",{"relative","parts"},Path_Create);
|
dict->DeclareFunction(gc,"Create","Create a Path from parts",{"relative","parts"},Path_Create);
|
||||||
dict->DeclareFunction(gc,"Root","Create Absolute Root Path",{}, Path_Root);
|
dict->DeclareFunction(gc,"Root","Create Absolute Root Path",{}, Path_Root);
|
||||||
env->DeclareVariable("Path", dict);
|
env->DeclareVariable("Path", dict);
|
||||||
|
|||||||
@ -1922,6 +1922,34 @@ namespace Tesses::CrossLang {
|
|||||||
cse.back()->Push(gc, path.GetExtension());
|
cse.back()->Push(gc, path.GetExtension());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if(cse.back()->env->GetRootEnvironment()->permissions.canRegisterLocalFS && key == "MakeAbsolute")
|
||||||
|
{
|
||||||
|
Tesses::Framework::Filesystem::VFSPath p;
|
||||||
|
if(GetArgumentAsPath(args,0,p))
|
||||||
|
{
|
||||||
|
cse.back()->Push(gc,path.MakeAbsolute(p));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cse.back()->Push(gc,path.MakeAbsolute());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(cse.back()->env->GetRootEnvironment()->permissions.canRegisterLocalFS && key == "MakeRelative")
|
||||||
|
{
|
||||||
|
Tesses::Framework::Filesystem::VFSPath p;
|
||||||
|
if(GetArgumentAsPath(args,0,p))
|
||||||
|
{
|
||||||
|
cse.back()->Push(gc,path.MakeRelative(p));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cse.back()->Push(gc,path.MakeRelative());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(key == "ChangeExtension")
|
if(key == "ChangeExtension")
|
||||||
{
|
{
|
||||||
Tesses::Framework::Filesystem::VFSPath newPath = path;
|
Tesses::Framework::Filesystem::VFSPath newPath = path;
|
||||||
|
|||||||
Reference in New Issue
Block a user