DynuIPRefresher/src/FileLogger.cpp

34 lines
535 B
C++
Raw Normal View History

2019-10-26 14:41:43 +02:00
//
// Created by lukas on 05.05.19.
//
#include <fstream>
#include <iostream>
2020-05-05 19:15:08 +02:00
#include <climits>
2019-10-26 14:41:43 +02:00
#include "FileLogger.h"
void FileLogger::safeip(std::string ip) {
std::ofstream out;
out.open("ip.txt", std::ios::out);
out << ip;
out.close();
}
std::string FileLogger::readip() {
std::ifstream in;
in.open("ip.txt", std::ios::in);
std::string ip;
in >> ip;
2020-05-05 19:15:08 +02:00
// when received ip has no : return 0.0.0.0
if (ip.find(':') == ULONG_MAX)
return "0.0.0.0";
else
return ip;
2019-10-26 14:41:43 +02:00
}