FileReader.cpp 494 B

1234567891011121314151617181920212223
  1. //
  2. // Created by xcbosa on 2023/1/28.
  3. //
  4. #include "utils-private.h"
  5. #include "../webuiconf.h"
  6. using namespace std;
  7. namespace xc::utils {
  8. string contentsOfTextFile(string filePath) {
  9. ifstream fin(filePath);
  10. if (fin.fail()) {
  11. cerr << "[FileIOError]: " << ::strerror(errno) << endl;
  12. return "404";
  13. }
  14. stringstream buffer;
  15. buffer << fin.rdbuf();
  16. string str(buffer.str());
  17. fin.close();
  18. return str;
  19. }
  20. }