mirror of
https://onedev.site.tesses.net/tesses-framework
synced 2026-02-08 15:55:46 +00:00
Allow you do explicitly close stream, vfs
This commit is contained in:
@@ -39,7 +39,6 @@ namespace Tesses::Framework::Filesystem
|
|||||||
|
|
||||||
void Chmod(VFSPath path, uint32_t mode);
|
void Chmod(VFSPath path, uint32_t mode);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
extern std::shared_ptr<LocalFilesystem> LocalFS;
|
extern std::shared_ptr<LocalFilesystem> LocalFS;
|
||||||
}
|
}
|
||||||
@@ -94,6 +94,7 @@ namespace Tesses::Framework::Filesystem
|
|||||||
VFSPath SystemToVFSPath(std::string path);
|
VFSPath SystemToVFSPath(std::string path);
|
||||||
void GetDate(VFSPath path, Date::DateTime& lastWrite, Date::DateTime& lastAccess);
|
void GetDate(VFSPath path, Date::DateTime& lastWrite, Date::DateTime& lastAccess);
|
||||||
void SetDate(VFSPath path, Date::DateTime lastWrite, Date::DateTime lastAccess);
|
void SetDate(VFSPath path, Date::DateTime lastWrite, Date::DateTime lastAccess);
|
||||||
|
|
||||||
~MemoryFilesystem();
|
~MemoryFilesystem();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -57,5 +57,6 @@ namespace Tesses::Framework::Filesystem
|
|||||||
|
|
||||||
void Chmod(VFSPath path, uint32_t mode);
|
void Chmod(VFSPath path, uint32_t mode);
|
||||||
|
|
||||||
|
void Close();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -153,5 +153,7 @@ namespace Tesses::Framework::Filesystem
|
|||||||
virtual void Chmod(VFSPath path, uint32_t mode);
|
virtual void Chmod(VFSPath path, uint32_t mode);
|
||||||
|
|
||||||
virtual ~VFS();
|
virtual ~VFS();
|
||||||
|
|
||||||
|
virtual void Close();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,7 @@ namespace Tesses::Framework::Streams
|
|||||||
size_t Write(const uint8_t* buff, size_t sz);
|
size_t Write(const uint8_t* buff, size_t sz);
|
||||||
|
|
||||||
~BufferedStream();
|
~BufferedStream();
|
||||||
|
void Close();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -23,6 +23,6 @@ namespace Tesses::Framework::Streams
|
|||||||
void Flush();
|
void Flush();
|
||||||
void Seek(int64_t pos, SeekOrigin whence);
|
void Seek(int64_t pos, SeekOrigin whence);
|
||||||
~FileStream();
|
~FileStream();
|
||||||
|
void Close();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,6 @@ namespace Tesses::Framework::Streams
|
|||||||
int64_t GetLength();
|
int64_t GetLength();
|
||||||
int64_t GetPosition();
|
int64_t GetPosition();
|
||||||
void Seek(int64_t pos, SeekOrigin whence);
|
void Seek(int64_t pos, SeekOrigin whence);
|
||||||
|
void Close();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -53,5 +53,6 @@ namespace Tesses::Framework::Streams
|
|||||||
static std::vector<std::pair<std::string,std::string>> GetIPs(bool ipV6=false);
|
static std::vector<std::pair<std::string,std::string>> GetIPs(bool ipV6=false);
|
||||||
~NetworkStream();
|
~NetworkStream();
|
||||||
void SetNoDelay(bool noDelay);
|
void SetNoDelay(bool noDelay);
|
||||||
|
void Close();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -25,5 +25,6 @@ namespace Tesses::Framework::Streams
|
|||||||
void Resize(WindowSize sz);
|
void Resize(WindowSize sz);
|
||||||
WindowSize GetWindowSize();
|
WindowSize GetWindowSize();
|
||||||
~PtyStream();
|
~PtyStream();
|
||||||
|
void Close();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@ namespace Tesses::Framework::Streams
|
|||||||
virtual void Flush();
|
virtual void Flush();
|
||||||
virtual void Seek(int64_t pos, SeekOrigin whence);
|
virtual void Seek(int64_t pos, SeekOrigin whence);
|
||||||
void CopyTo(std::shared_ptr<Stream> strm, size_t buffSize=1024);
|
void CopyTo(std::shared_ptr<Stream> strm, size_t buffSize=1024);
|
||||||
|
virtual void Close();
|
||||||
virtual ~Stream();
|
virtual ~Stream();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
namespace Tesses::Framework::Filesystem
|
namespace Tesses::Framework::Filesystem
|
||||||
{
|
{
|
||||||
|
|
||||||
MemoryFilesystemStream::MemoryFilesystemStream(std::shared_ptr<Tesses::Framework::Threading::Mutex> mtx, std::shared_ptr<MemoryFileData> data,bool canRead, bool canWrite, bool canSeek)
|
MemoryFilesystemStream::MemoryFilesystemStream(std::shared_ptr<Tesses::Framework::Threading::Mutex> mtx, std::shared_ptr<MemoryFileData> data,bool canRead, bool canWrite, bool canSeek)
|
||||||
{
|
{
|
||||||
this->mtx = mtx;
|
this->mtx = mtx;
|
||||||
|
|||||||
@@ -21,6 +21,13 @@ namespace Tesses::Framework::Filesystem
|
|||||||
for(auto item : this->directories) delete item;
|
for(auto item : this->directories) delete item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MountableFilesystem::Close()
|
||||||
|
{
|
||||||
|
this->root=nullptr;
|
||||||
|
for(auto item : this->directories) delete item;
|
||||||
|
this->directories.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MountableFilesystem::GetFS(VFSPath srcPath, VFSPath& destRoot, VFSPath& destPath, std::shared_ptr<VFS>& vfs)
|
void MountableFilesystem::GetFS(VFSPath srcPath, VFSPath& destRoot, VFSPath& destPath, std::shared_ptr<VFS>& vfs)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -517,5 +517,7 @@ namespace Tesses::Framework::Filesystem
|
|||||||
void VFS::Chmod(VFSPath path, uint32_t mode) {
|
void VFS::Chmod(VFSPath path, uint32_t mode) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
void VFS::Close() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -58,4 +58,9 @@ namespace Tesses::Framework::Streams {
|
|||||||
{
|
{
|
||||||
delete buffer;
|
delete buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BufferedStream::Close()
|
||||||
|
{
|
||||||
|
this->strm->Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,10 @@ namespace Tesses::Framework::Streams
|
|||||||
}
|
}
|
||||||
FileStream::~FileStream()
|
FileStream::~FileStream()
|
||||||
{
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
void FileStream::Close()
|
||||||
|
{
|
||||||
if(!f) return;
|
if(!f) return;
|
||||||
if(this->owns)
|
if(this->owns)
|
||||||
fclose(this->f);
|
fclose(this->f);
|
||||||
|
|||||||
@@ -67,4 +67,8 @@ namespace Tesses::Framework::Streams
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void MemoryStream::Close()
|
||||||
|
{
|
||||||
|
this->buffer.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -771,10 +771,15 @@ namespace Tesses::Framework::Streams {
|
|||||||
if(sz2 < 0) return 0;
|
if(sz2 < 0) return 0;
|
||||||
return (size_t)sz2;
|
return (size_t)sz2;
|
||||||
}
|
}
|
||||||
NetworkStream::~NetworkStream()
|
void NetworkStream::Close()
|
||||||
{
|
{
|
||||||
if(this->owns && this->success)
|
if(this->owns && this->success)
|
||||||
NETWORK_CLOSE(this->sock);
|
NETWORK_CLOSE(this->sock);
|
||||||
|
this->success=0;
|
||||||
|
}
|
||||||
|
NetworkStream::~NetworkStream()
|
||||||
|
{
|
||||||
|
Close();
|
||||||
}
|
}
|
||||||
void NetworkStream::SetNoDelay(bool noDelay)
|
void NetworkStream::SetNoDelay(bool noDelay)
|
||||||
{
|
{
|
||||||
@@ -888,6 +893,10 @@ NetworkStream::~NetworkStream()
|
|||||||
void NetworkStream::SetNoDelay(bool noDelay)
|
void NetworkStream::SetNoDelay(bool noDelay)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void NetworkStream::Close()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
uint16_t NetworkStream::GetPort()
|
uint16_t NetworkStream::GetPort()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -122,6 +122,11 @@ namespace Tesses::Framework::Streams {
|
|||||||
}
|
}
|
||||||
PtyStream::~PtyStream()
|
PtyStream::~PtyStream()
|
||||||
{
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
void PtyStream::Close()
|
||||||
|
{
|
||||||
|
if(this->eos) return;
|
||||||
this->eos=true;
|
this->eos=true;
|
||||||
#if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) && defined(TESSESFRAMEWORK_ENABLE_PROCESS)
|
#if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) && defined(TESSESFRAMEWORK_ENABLE_PROCESS)
|
||||||
close(this->socket);
|
close(this->socket);
|
||||||
|
|||||||
@@ -91,6 +91,10 @@ namespace Tesses::Framework::Streams {
|
|||||||
void Stream::Seek(int64_t pos, SeekOrigin whence)
|
void Stream::Seek(int64_t pos, SeekOrigin whence)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void Stream::Close()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stream::CopyTo(std::shared_ptr<Stream> strm, size_t buffSize)
|
void Stream::CopyTo(std::shared_ptr<Stream> strm, size_t buffSize)
|
||||||
|
|||||||
Reference in New Issue
Block a user