diff --git a/source/simple/file.hpp b/source/simple/file.hpp index 5f5fb34d5ebc76e22821f5d6c8ebeb4a19cfcb44..84e2f7c9670e19fcd5786c4177bc42a5e7eef8d1 100644 --- a/source/simple/file.hpp +++ b/source/simple/file.hpp @@ -1,5 +1,5 @@ -#ifndef _SIMPLE_FILE_HPP -#define _SIMPLE_FILE_HPP +#ifndef SIMPLE_FILE_HPP +#define SIMPLE_FILE_HPP #include <iosfwd> #include <type_traits> @@ -159,11 +159,23 @@ namespace string_stack inline size_type size(stream&& file) { + // TODO FIXME: does not work on text steams and generally is undefined behavior apparently -_- file.seekg(0, file.end); auto ret = file.tellg(); return ret; } + // supa slow way + std::streamsize defined_size(stream& file) + { + file.ignore( std::numeric_limits<std::streamsize>::max() ); + std::streamsize size = file.gcount(); + file.clear(); + file.seekg( 0, file.beg ); + return size; + } + // just read it (trollface) + inline void dump(stream& from, char* to, size_type this_much) { auto _size = size(from);