[pan: 9/15] Remove some fudging in file_util.h
- From: Dominique Dumont <ddumont src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan: 9/15] Remove some fudging in file_util.h
- Date: Sun, 12 Jun 2022 09:12:12 +0000 (UTC)
commit eaca76cdad4331e3d943a20c68c617063ba43062
Author: Thomas Tanner <thosrtanner googlemail com>
Date: Thu Jun 2 22:04:52 2022 +0100
Remove some fudging in file_util.h
pan/data/cert-store.cc | 9 +++++----
pan/general/file-util.h | 10 ----------
pan/gui/gui.cc | 13 +++++--------
pan/gui/post-ui.cc | 3 ++-
pan/gui/prefs-ui.cc | 6 +++++-
pan/gui/task-pane.cc | 8 ++++++--
pan/tasks/encoder.cc | 1 +
pan/tasks/task-upload.cc | 6 +++++-
8 files changed, 29 insertions(+), 27 deletions(-)
---
diff --git a/pan/data/cert-store.cc b/pan/data/cert-store.cc
index dc1f2e1..53b60d8 100644
--- a/pan/data/cert-store.cc
+++ b/pan/data/cert-store.cc
@@ -22,8 +22,9 @@
#include <string>
-//#include <glib/giochannel.h>
-//#include <glib/gstring.h>
+extern "C" {
+ #include <sys/stat.h>
+}
#include <pan/tasks/socket.h>
#include <config.h>
@@ -340,7 +341,7 @@ bool CertStore::add(gnutls_x509_crt_t cert, const Quark& server) {
cert_file_name = buffer.str();
cert_file_name_wp = file::absolute_fn("ssl_certs", cert_file_name);
- FILE * fp = fopen(cert_file_name_wp.c_str(), "wb");
+ FILE * fp = fopen(cert_file_name_wp.c_str(), "wb");
if (!fp)
return false;
@@ -362,7 +363,7 @@ bool CertStore::add(gnutls_x509_crt_t cert, const Quark& server) {
} else {
fputs((const char*) out, fp);
}
-
+
debug_SSL_verbatim("\n===========================================");
debug_SSL_verbatim(out);
debug_SSL_verbatim("\n===========================================");
diff --git a/pan/general/file-util.h b/pan/general/file-util.h
index 8c67639..59314ec 100644
--- a/pan/general/file-util.h
+++ b/pan/general/file-util.h
@@ -27,18 +27,8 @@ extern "C" {
#include <stdio.h>
}
#include <glib.h>
-#include <glib/gstdio.h>
#include <pan/general/string-view.h>
-#define g_freopen freopen
-#define g_fopen fopen
-#define g_rmdir rmdir
-#define g_remove remove
-#define g_unlink unlink
-#define g_lstat lstat
-#define g_stat stat
-#define g_rename rename
-#define g_open open
namespace pan
{
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index df4d8c3..03a2bd9 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -16,10 +16,6 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
-#if defined(G_OS_UNIX) && !defined(G_STDIO_WRAP_ON_UNIX)
-#include <fcntl.h> //Because you need to >.<
-#endif
-#include <glib-2.0/glib/gstdio.h>
#include <config.h>
#include <map>
@@ -2397,12 +2393,13 @@ GUI :: do_edit_scores (GtkAction *a)
//This is wrong because this might not be the filename
char *filename = g_build_filename(file::get_pan_home().c_str(), "Score", NULL);
if (not file::file_exists(filename)) {
- GError *err{nullptr};
- g_close(g_creat(filename, 0700), &err);
- if (err != nullptr) {
- //log error
+ FILE *f = fopen(filename, "a+");
+ if (f == nullptr) {
+ Log::add_err_va("Error creating file '%s'", filename);
+ g_free(filename);
return;
}
+ fclose(f);
}
using namespace std::placeholders;
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index c9dc4f4..238b2c2 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -26,6 +26,7 @@
#include <glib/gi18n.h>
#include "gtk-compat.h"
extern "C" {
+ #include <sys/stat.h>
#include <sys/time.h>
}
#ifdef HAVE_GTKSPELL
@@ -1357,7 +1358,7 @@ PostUI :: spawn_editor ()
Destroyer d(fname);
- FILE *fp = g_fopen (fname, "w");
+ FILE *fp = fopen (fname, "w");
if (fp == NULL) {
return;
}
diff --git a/pan/gui/prefs-ui.cc b/pan/gui/prefs-ui.cc
index d83cb22..2c33c0e 100644
--- a/pan/gui/prefs-ui.cc
+++ b/pan/gui/prefs-ui.cc
@@ -34,6 +34,10 @@
#include "e-charset-dialog.h"
#include "actions-extern.h"
+extern "C" {
+ #include <sys/stat.h>
+}
+
#include <algorithm>
using namespace pan;
@@ -1279,7 +1283,7 @@ PrefsDialog :: PrefsDialog (Prefs& prefs, GtkWindow* parent):
pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("text-color-bg", def_color_str, prefs));
HIG :: workarea_add_row (t, &row, _("Text Color:"), h);
HIG :: workarea_finish (t, &row);
-
+
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), t, new_label_with_icon(_("_Colors"), _("Colors"),
icon_prefs_colors, prefs));
// Applications
diff --git a/pan/gui/task-pane.cc b/pan/gui/task-pane.cc
index 3ca97f0..f88e8b8 100644
--- a/pan/gui/task-pane.cc
+++ b/pan/gui/task-pane.cc
@@ -34,6 +34,10 @@
#include "task-pane.h"
#include "taskpane.ui.h"
+extern "C" {
+ #include <sys/stat.h>
+}
+
enum
{
COL_TASK_POINTER,
@@ -144,8 +148,8 @@ namespace
void
TaskPane :: show_task_info(const tasks_t& tasks)
{
-
- if (tasks.size() == 0) return;
+
+ if (tasks.size() == 0) return;
Task* task (tasks.front());
if (!task) return;
diff --git a/pan/tasks/encoder.cc b/pan/tasks/encoder.cc
index fad9a63..9b2bb7f 100644
--- a/pan/tasks/encoder.cc
+++ b/pan/tasks/encoder.cc
@@ -32,6 +32,7 @@
#include <uulib/uudeview.h>
#include <glib/gi18n.h>
extern "C" {
+#include <sys/stat.h>
#include <sys/time.h>
};
diff --git a/pan/tasks/task-upload.cc b/pan/tasks/task-upload.cc
index acf8d2f..554a4f9 100644
--- a/pan/tasks/task-upload.cc
+++ b/pan/tasks/task-upload.cc
@@ -29,6 +29,10 @@
#include <fstream>
#include <cstdio>
+extern "C" {
+#include <sys/stat.h>
+}
+
#include <pan/general/debug.h>
#include <pan/general/file-util.h>
#include <pan/general/log.h>
@@ -203,7 +207,7 @@ TaskUpload :: prepend_headers(GMimeMessage* msg, TaskUpload::Needed * n, std::st
if (!mids.empty()) g_mime_object_set_header ((GMimeObject *) msg, "References", mids.c_str(), NULL);
char * all(g_mime_object_get_headers ((GMimeObject *) msg, NULL));
-
+
if (_first && _queue_pos==-1)
all = g_mime_object_to_string ((GMimeObject *) msg, NULL);
else if (_first && _queue_pos == 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]