ProfinetConnector/src/file_api/file_api.cpp

26 lines
727 B
C++
Raw Normal View History

#include "file_api.hpp"
std::ifstream fileapi_read_file( std::filesystem::path filepath, std::ostream & info)
{
if( not std::filesystem::exists( filepath ) )
throw std::invalid_argument{ "File: " + filepath.string() + " does not exist." };
if( not std::filesystem::is_regular_file( filepath ) )
throw std::invalid_argument{"File: " + filepath.string() + " is not a file."};
info << "File: " + filepath.string() + " is valid." << std::endl;
return { filepath };
}
std::string fileapi_read_full_stream( std::ifstream _is )
{
std::string file_;
while( _is ){
std::string file_str;
_is >> file_str;
file_ += file_str;
}
return file_;
}