portable c-code for reading pingback/announcement message

This commit is contained in:
Robin Gareus 2015-09-08 21:21:28 +02:00
parent dee324cc36
commit 2f1878a6f7
2 changed files with 9 additions and 18 deletions

View File

@ -807,20 +807,18 @@ ARDOUR_UI::check_announcements ()
#endif
_annc_filename.append (VERSIONSTRING);
_announce_string = "";
std::string path = Glib::build_filename (user_config_directory(), _annc_filename);
FILE* fin = g_fopen (path.c_str(), "rb");
if (fin) {
std::ifstream announce_file (fin);
if ( announce_file.fail() )
_announce_string = "";
else {
std::stringstream oss;
oss << announce_file.rdbuf();
_announce_string = oss.str();
while (!feof (fin)) {
char tmp[1024];
if (fread (tmp, sizeof(char), 1024, fin) <= 0) {
break;
}
_announce_string += fin
}
fclose (fin);
}

View File

@ -226,14 +226,7 @@ _pingback (void *arg)
FILE* fout = g_fopen (cm->announce_path.c_str(), "wb");
if (fout) {
{
std::ofstream annc_file (fout);
if (annc_file) {
annc_file << return_str;
}
}
fwrite (return_str.c_str(), sizeof(char), return_str.length (), fout);
fclose (fout);
}
}