25 #include <glib/gstdio.h> 30 #include <sys/types.h> 68 if (!filename || filename[0] ==
'\0')
return 0;
73 if (!fullname)
return 0;
76 fd = g_open( fullname, O_RDONLY, 0 );
84 PERR (
"file %s: (%d) %s\n", filename, norr, strerror(norr));
89 size = lseek( fd, 0, SEEK_END );
90 lseek( fd, 0, SEEK_SET );
95 PERR (
"file seek-to-end %s: (%d) %s\n", filename, norr, strerror(norr));
100 buf = g_new(
char, (
size_t)size + 1);
103 if ( read(fd, buf, (
size_t)size) == -1 )
110 buf[(size_t)size] =
'\0';
139 g_return_val_if_fail(line, -1);
141 g_return_val_if_fail(file, -1);
143 gs = g_string_new(
"");
145 while (fgets(str,
sizeof(str), file) != NULL)
147 g_string_append(gs, str);
150 if (str[len-1] ==
'\n')
155 *line = g_string_free (gs, FALSE);
#define G_LOG_DOMAIN
Functions providing the SX List as a plugin page.
GKeyFile helper routines.
#define PERR(format, args...)
Log a serious error.
gint64 gnc_getline(gchar **line, FILE *file)
Read a line from the input file, up to and including the newline.
All type declarations for the whole Gnucash engine.
Utility functions for file access.
gchar * gnc_path_find_localized_html_file(const gchar *file_name)
Find an absolute path to a localized version of a given relative path to a html or html related file...
Utility functions for convert uri in separate components and back.
File path resolution utility functions.
int gncReadFile(const char *filename, char **data)
Reads the contents of a file into a buffer for further processing.