40 #include "utilities.h"
46 if (directory == NULL)
52 gint status = g_stat(directory, &buffer);
54 if (status == 0 && S_ISDIR(buffer.st_mode) != 0)
70 gint status = g_stat(fname, &buffer);
72 if (status == 0 && S_ISREG(buffer.st_mode) != 0)
84 gint fname_status_size = (strlen(filename) + 255);
85 gchar *fname_status = g_malloc(
sizeof(
char) * fname_status_size);
86 g_snprintf(fname_status, fname_status_size,
87 _(
"Processing file '%s' ..."), filename);
100 if (filename == NULL)
105 gint index = strlen(filename) - 1;
108 if (filename[index] ==
'\n' ||
109 filename[index] ==
'\r')
111 filename[index] =
'\0';
113 else if (filename[index] !=
'\0')
139 if (!(g_utf8_validate (text, -1,NULL)) && (text != NULL))
141 temp = g_convert(text, -1,
"UTF-8",
"ISO-8859-1", &bytes_read, &bytes_written, NULL);
147 *must_be_freed = TRUE;
152 *must_be_freed = FALSE;
157 void build_path(GString *path,
const gchar *dir,
const gchar *filename)
160 g_string_assign(path,
".");
161 g_string_append(path, G_DIR_SEPARATOR_S);
162 g_string_append(path, filename);
164 if (strlen(dir) == 0)
166 g_string_assign(path, filename);
170 g_string_assign(path, dir);
171 g_string_append(path, G_DIR_SEPARATOR_S);
172 g_string_append(path, filename);
177 gboolean double_equals(gdouble double_to_compare, gdouble compared_value)
179 return fabs(double_to_compare - compared_value) < DOUBLE_PRECISION;
void remove_end_slash_n_r_from_filename(char *filename)
Removes trailing \r or \n characters from a filename.
gint file_exists(const gchar *fname)
check if specified file exists
void print_processing_file(gchar *filename, ui_state *ui)
Issues the message "Processing file <filename>" into the message bar.
gchar * transform_to_utf8(gchar *text, gint free_or_not, gint *must_be_freed)
transform text to utf8
void put_status_message(const gchar *text, ui_state *ui)
Output a info message to the status message bar.
gint directory_exists(const gchar *directory)
check if specified directory exists