~widelands-dev/widelands/trunk

« back to all changes in this revision

Viewing changes to src/io/dedicated_log.cc

  • Committer: fios at foramnagaidhlig
  • Date: 2014-09-29 19:25:24 UTC
  • mfrom: (7181.2.9 bug-1343299)
  • Revision ID: fios@foramnagaidhlig.net-20140929192524-0yvtkgom31yhejri
Refactoring: removed CamelCase etc from function names.

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
        temp += c.sender.empty() ? "SYSTEM" : c.sender;
98
98
        temp += "</td><td class=\"recipient\"> ->" + c.recipient + "</td><td class=\"message\">";
99
99
        temp += c.msg + "</td></tr>\n";
100
 
        m_chat.Printf("%s", temp.c_str());
101
 
        m_chat.WriteAppend(*root, m_chat_file_path.c_str());
 
100
        m_chat.print_f("%s", temp.c_str());
 
101
        m_chat.write_append(*root, m_chat_file_path.c_str());
102
102
}
103
103
 
104
104
/// Add's a spacer to the chat log
105
 
void DedicatedLog::chatAddSpacer() {
 
105
void DedicatedLog::chat_add_spacer() {
106
106
        if (m_chat_file_path.empty())
107
107
                return;
108
108
 
109
 
        m_chat.Printf("<tr><td class=\"space\"></td><td class=\"space\"></td>");
110
 
        m_chat.Printf("<td class=\"space\"></td><td class=\"space\"></td></tr>\n");
111
 
        m_chat.WriteAppend(*root, m_chat_file_path.c_str());
 
109
        m_chat.print_f("<tr><td class=\"space\"></td><td class=\"space\"></td>");
 
110
        m_chat.print_f("<td class=\"space\"></td><td class=\"space\"></td></tr>\n");
 
111
        m_chat.write_append(*root, m_chat_file_path.c_str());
112
112
}
113
113
 
114
114
 
206
206
                }
207
207
        }
208
208
        temp += "</table>\n";
209
 
        m_chat.Printf("%s", temp.c_str());
210
 
        m_chat.Write(*root, m_info_file_path.c_str());
 
209
        m_chat.print_f("%s", temp.c_str());
 
210
        m_chat.write(*root, m_info_file_path.c_str());
211
211
}
212
212
 
213
213
/// Appends the String \arg msg to the log file
224
224
        temp += "</td><td class=\"log\">";
225
225
        temp += msg;
226
226
        temp += "</td></tr>\n";
227
 
        m_chat.Printf("%s", temp.c_str());
228
 
        m_chat.WriteAppend(*root, m_log_file_path.c_str());
 
227
        m_chat.print_f("%s", temp.c_str());
 
228
        m_chat.write_append(*root, m_log_file_path.c_str());
229
229
}
230
230
 
231
231
 
252
252
        m_chat_file_path = path;
253
253
 
254
254
        // Initialize the chat file
255
 
        m_chat.Printf("<tr><th>Time</th><th>Sender</th><th>Recipient</th><th>Message</th></tr>");
256
 
        m_chat.Write(*root, m_chat_file_path.c_str()); // Not WriteAppend, to make sure the file is cleared
 
255
        m_chat.print_f("<tr><th>Time</th><th>Sender</th><th>Recipient</th><th>Message</th></tr>");
 
256
        m_chat.write(*root, m_chat_file_path.c_str()); // Not write_append, to make sure the file is cleared
257
257
        return true;
258
258
}
259
259
 
307
307
        m_log_file_path = path;
308
308
 
309
309
        // Initialize the log file
310
 
        m_chat.Printf("<tr><th></th><th>Widelands dedicated server log:</th></tr>\n");
311
 
        m_chat.Write(*root, m_log_file_path.c_str()); // Not WriteAppend, to make sure the file is cleared
 
310
        m_chat.print_f("<tr><th></th><th>Widelands dedicated server log:</th></tr>\n");
 
311
        m_chat.write(*root, m_log_file_path.c_str()); // Not write_append, to make sure the file is cleared
312
312
        return true;
313
313
}
314
314
 
323
323
 *          written to does not exist, in all other cases true.
324
324
 */
325
325
bool DedicatedLog::check_file_writeable(std::string & path) {
326
 
        bool existing = root->FileExists(path);
327
 
        if (existing && root->IsDirectory(path))
 
326
        bool existing = root->file_exists(path);
 
327
        if (existing && root->is_directory(path))
328
328
                return false;
329
 
        if (root->FileIsWriteable(path)) {
 
329
        if (root->file_is_writeable(path)) {
330
330
                if (existing) {
331
331
                        std::string rnpath(path + '~');
332
 
                        if (root->FileIsWriteable(rnpath))
333
 
                                root->Rename(path, rnpath);
 
332
                        if (root->file_is_writeable(rnpath))
 
333
                                root->fs_rename(path, rnpath);
334
334
                        else
335
335
                                log("Note: original file %s could not be backuped\n", path.c_str());
336
336
                }