mirror of
https://onedev.site.tesses.net/crosslang
synced 2026-04-16 07:57:02 +00:00
Added FS.MemoryFilesystem
This commit is contained in:
@@ -35,6 +35,10 @@ namespace Tesses::CrossLang
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
static TObject FS_CreateMemoryFilesystem(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
return TVFSHeapObject::Create(ls, new Tesses::Framework::Filesystem::MemoryFilesystem());
|
||||
}
|
||||
|
||||
static TObject FS_CreateFilesystem(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
@@ -71,6 +75,41 @@ namespace Tesses::CrossLang
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
static TObject FS_CreateArchive(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
TVFSHeapObject* vfs;
|
||||
TStreamHeapObject* strm;
|
||||
std::string name;
|
||||
std::string version;
|
||||
std::string info;
|
||||
TVMVersion version2;
|
||||
|
||||
if(GetArgumentHeap(args,0,vfs) && GetArgumentHeap(args,1,strm) && GetArgument(args,2,name) && GetArgument(args,3,version) && GetArgument(args,4,info) && TVMVersion::TryParse(version,version2))
|
||||
{
|
||||
CrossArchiveCreate(vfs->vfs,strm->stream,name,version2,info);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
static TObject FS_ExtractArchive(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
TVFSHeapObject* vfs;
|
||||
TStreamHeapObject* strm;
|
||||
|
||||
if(GetArgumentHeap(args,0,strm) && GetArgumentHeap(args,1,vfs))
|
||||
{
|
||||
auto res = CrossArchiveExtract(strm->stream,vfs->vfs);
|
||||
|
||||
TDictionary* dict = TDictionary::Create(ls);
|
||||
ls.GetGC()->BarrierBegin();
|
||||
dict->SetValue("Name",res.first.first);
|
||||
dict->SetValue("Version",res.first.second.ToString());
|
||||
dict->SetValue("Info",res.second);
|
||||
ls.GetGC()->BarrierEnd();
|
||||
return dict;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void TStd::RegisterIO(GC* gc,TRootEnvironment* env,bool enableLocalFilesystem)
|
||||
{
|
||||
|
||||
@@ -93,6 +132,10 @@ namespace Tesses::CrossLang
|
||||
dict->DeclareFunction(gc, "MemoryStream","Create a memory stream",{"writable"}, FS_MemoryStream);
|
||||
dict->DeclareFunction(gc, "CreateStream","Create stream", {"strm"},FS_CreateStream);
|
||||
dict->DeclareFunction(gc, "CreateFilesystem","Create filesystem", {"fs"},FS_CreateFilesystem);
|
||||
|
||||
dict->DeclareFunction(gc, "CreateMemoryFilesystem","Create in memory filesystem", {},FS_CreateMemoryFilesystem);
|
||||
dict->DeclareFunction(gc, "CreateArchive", "Create a crvm archive",{"fs","strm","name","version","info"},FS_CreateArchive);
|
||||
dict->DeclareFunction(gc,"ExtractArchive", "Extract a crvm archive",{"strm","vfs"},FS_ExtractArchive);
|
||||
env->DeclareVariable("FS", dict);
|
||||
gc->BarrierEnd();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user