diff --git a/include/CrossLang.hpp b/include/CrossLang.hpp index d9dc154..290c3b5 100644 --- a/include/CrossLang.hpp +++ b/include/CrossLang.hpp @@ -2023,6 +2023,7 @@ class GC { Tesses::Framework::Filesystem::VFSPath SystemToVFSPath(std::string path); void GetDate(Tesses::Framework::Filesystem::VFSPath path, Tesses::Framework::Date::DateTime& lastWrite, Tesses::Framework::Date::DateTime& lastAccess); void SetDate(Tesses::Framework::Filesystem::VFSPath path, Tesses::Framework::Date::DateTime lastWrite, Tesses::Framework::Date::DateTime lastAccess); + void Close(); ~TObjectVFS(); }; @@ -2043,6 +2044,7 @@ class GC { int64_t GetLength(); void Flush(); void Seek(int64_t pos, Tesses::Framework::Streams::SeekOrigin whence); + void Close(); ~TObjectStream(); }; diff --git a/src/runtime_methods/console.cpp b/src/runtime_methods/console.cpp index 230ac67..2b9cefb 100644 --- a/src/runtime_methods/console.cpp +++ b/src/runtime_methods/console.cpp @@ -262,7 +262,7 @@ namespace Tesses::CrossLang { } } - std::cout << std::setw(3) << progress << "%" << std::flush; + std::cout << std::setw(3) << (int)(pdbl*100) << "%" << std::flush; return Undefined(); } TObject Console_getSize(GCList& ls, std::vector args) diff --git a/src/runtime_methods/helpers.cpp b/src/runtime_methods/helpers.cpp index 3ee4d37..07442eb 100644 --- a/src/runtime_methods/helpers.cpp +++ b/src/runtime_methods/helpers.cpp @@ -12,23 +12,24 @@ namespace Tesses::CrossLang { callable->Call(ls,{0.0}); if(len > 0) { - std::shared_ptr buff=std::make_shared(1024); + std::vector buff(1024); int64_t pos=0; int curPercent=0; int lastPercent=0; size_t read = 0; do { - read = src->ReadBlock(buff.get(),1024); - dest->WriteBlock(buff.get(),read); + read = src->ReadBlock(buff.data(),buff.size()); + dest->WriteBlock(buff.data(),read); if(read == 0) break; pos += (int64_t)read; - double percent = (double)(pos / len); - percent *= 10000; - + double percent = ((double)pos / len); + percent *= 10000.0; + curPercent = (int)percent; + if(curPercent > lastPercent) { lastPercent = curPercent; diff --git a/src/types/streamheapobject.cpp b/src/types/streamheapobject.cpp index d8bf408..afb8018 100644 --- a/src/types/streamheapobject.cpp +++ b/src/types/streamheapobject.cpp @@ -200,8 +200,17 @@ namespace Tesses::CrossLang } } + void TObjectStream::Close() + { + TDictionary* dict; + if(GetObjectHeap(this->obj, dict)) + { + dict->CallMethod(*ls,"Close",{}); + } + } TObjectStream::~TObjectStream() { + Close(); delete this->ls; } diff --git a/src/types/vfsheapobject.cpp b/src/types/vfsheapobject.cpp index 58d086c..a4a3ca6 100644 --- a/src/types/vfsheapobject.cpp +++ b/src/types/vfsheapobject.cpp @@ -501,15 +501,19 @@ namespace Tesses::CrossLang { } } - TObjectVFS::~TObjectVFS() + void TObjectVFS::Close() { - TDictionary* dict; if(GetObjectHeap(this->obj, dict)) { GCList ls(this->ls->GetGC()); - dict->CallMethod(ls,"Dispose",{}); + dict->CallMethod(ls,"Close",{}); } + } + TObjectVFS::~TObjectVFS() + { + + Close(); delete this->ls; } diff --git a/src/vm/vm.cpp b/src/vm/vm.cpp index 2b253d7..801f0bb 100644 --- a/src/vm/vm.cpp +++ b/src/vm/vm.cpp @@ -3483,6 +3483,12 @@ namespace Tesses::CrossLang { cse.back()->Push(gc, nullptr); return false; } + if(key == "Close") + { + strm->Close(); + cse.back()->Push(gc, nullptr); + return false; + } if(key == "Seek") { int64_t pos,whence; @@ -3594,7 +3600,12 @@ namespace Tesses::CrossLang { return false; } } - + if(key == "Close") + { + vfs->Close(); + cse.back()->Push(gc,nullptr); + return false; + } if(key == "EnumeratePaths") { Tesses::Framework::Filesystem::VFSPath dir;