1 /* 2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client 3 * Copyright (C) 1999-2018 Colin Leroy and the Claws Mail team 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef __CLAWS_IO_H__ 20 #define __CLAWS_IO_H__ 21 22 #ifdef HAVE_CONFIG_H 23 # include "config.h" 24 #include "claws-features.h" 25 #endif 26 27 #include <stdio.h> 28 #include <glib.h> 29 30 #if HAVE_FGETS_UNLOCKED 31 #define claws_fgets fgets_unlocked 32 #define claws_fgetc fgetc_unlocked 33 #define claws_fputs fputs_unlocked 34 #define claws_fputc fputc_unlocked 35 #define claws_fread fread_unlocked 36 #define claws_fwrite fwrite_unlocked 37 #define claws_feof feof_unlocked 38 #define claws_ferror ferror_unlocked 39 40 FILE *claws_fopen (const char *file, 41 const char *mode); 42 FILE *claws_fdopen (int fd, 43 const char *mode); 44 int claws_fclose (FILE *fp); 45 46 #else 47 48 #define claws_fgets fgets 49 #define claws_fgetc fgetc 50 #define claws_fputs fputs 51 #define claws_fputc fputc 52 #define claws_fread fread 53 #define claws_fwrite fwrite 54 #define claws_feof feof 55 #define claws_ferror ferror 56 #define claws_fopen g_fopen 57 #define claws_fdopen fdopen 58 #define claws_fclose fclose 59 #endif 60 61 int claws_safe_fclose (FILE *fp); 62 int claws_unlink (const char *filename); 63 64 gint file_strip_crs (const gchar *file); 65 gint append_file (const gchar *src, 66 const gchar *dest, 67 gboolean keep_backup); 68 gint copy_file (const gchar *src, 69 const gchar *dest, 70 gboolean keep_backup); 71 gint move_file (const gchar *src, 72 const gchar *dest, 73 gboolean overwrite); 74 gint copy_file_part_to_fp (FILE *fp, 75 off_t offset, 76 size_t length, 77 FILE *dest_fp); 78 gint copy_file_part (FILE *fp, 79 off_t offset, 80 size_t length, 81 const gchar *dest); 82 gint canonicalize_file (const gchar *src, 83 const gchar *dest); 84 gint canonicalize_file_replace (const gchar *file); 85 gchar *file_read_to_str (const gchar *file); 86 gchar *file_read_to_str_no_recode(const gchar *file); 87 gchar *file_read_stream_to_str (FILE *fp); 88 gchar *file_read_stream_to_str_no_recode(FILE *fp); 89 90 gint rename_force (const gchar *oldpath, 91 const gchar *newpath); 92 gint copy_dir (const gchar *src, 93 const gchar *dest); 94 gint change_file_mode_rw (FILE *fp, 95 const gchar *file); 96 FILE *my_tmpfile (void); 97 FILE *get_tmpfile_in_dir (const gchar *dir, 98 gchar **filename); 99 FILE *str_open_as_stream (const gchar *str); 100 gint str_write_to_file (const gchar *str, 101 const gchar *file, 102 gboolean safe); 103 104 #endif 105