text: #include "Pluto/Engine/FileSystem/NativeFile.h"
  
  namespace Pluto::Engine
  {
      NativeFile::NativeFile(FileStream stream) :
          _fileStream(std::move(stream))
      {
      }
  
      size_t NativeFile::GetSize()
      {
          const auto currentPosition = _fileStream.tellg();
          _fileStream.seekg(0, std::ios::end);
          const auto size = _fileStream.tellg();
          _fileStream.seekg(currentPosition);
          return size;
      }
  
      size_t NativeFile::GetPosition()
      {
          const auto currentPosition = _fileStream.tellg();
          return currentPosition;
      }
  
      void NativeFile::SetPosition(const size_t position)
      {
          const auto streamPosition = static_cast<std::streamsize>(position);
          _fileStream.seekg(streamPosition);
          _fileStream.seekp(streamPosition);
      }
  
      void NativeFile::ReadBytes(Byte* dst)
      {
          ReadBytes(GetSize(), dst);
      }
  
      void NativeFile::ReadBytes(const size_t size, Byte* dst)
      {
          ReadText(size, reinterpret_cast<char*>(dst));
      }
  
      void NativeFile::ReadBytes(Vector<Byte>& dst)
      {
          ReadBytes(GetSize(), dst);
      }
  
      void NativeFile::ReadBytes(const size_t size, Vector<Byte>& dst)
      {
          const size_t startIdx = dst.size();
          dst.resize(dst.size() + size);
          ReadBytes(size, &dst[startIdx]);
      }
  
      Vector<Byte> NativeFile::ReadBytes()
      {
          return ReadBytes(GetSize());
      }
  
      Vector<Byte> NativeFile::ReadBytes(const size_t size)
      {
          Vector<Byte> result;
          result.reserve(size);
          ReadBytes(size, result);
          return result;
      }
  
      void NativeFile::ReadText(const size_t size, char* dst)
      {
          const auto streamSize = static_cast<std::streamsize>(size);
          _fileStream.read(dst, streamSize);
      }
  
      String NativeFile::ReadText()
      {
          String str;
          str.resize(GetSize());
          ReadText(str.size(), str.data());
          return str;
      }
  
      void NativeFile::WriteBytes(const Byte* src, const size_t size)
      {
          WriteText(reinterpret_cast<const char*>(src), size);
      }
  
      void NativeFile::WriteBytes(const Vector<Byte>& src)
      {
          WriteBytes(src, src.size());
      }
  
      void NativeFile::WriteBytes(const Vector<Byte>& src, const size_t size)
      {
          WriteBytes(src.data(), size);
      }
  
      void NativeFile::WriteText(const char* src, const size_t size)
      {
          const auto streamSize = static_cast<std::streamsize>(size);
          _fileStream.write(src, streamSize);
      }
  
      void NativeFile::WriteText(const StringView str)
      {
          WriteText(str.data(), str.size());
      }
  
      Stream& NativeFile::GetStream()
      {
          return _fileStream;
      }
  
      void NativeFile::Flush()
      {
          _fileStream.flush();
      }
  }
  