static void rssyl_folder_read_existing_real(RFolderItem *ritem)
{
gchar *path = NULL, *fname = NULL;
- DIR *dp;
- struct dirent *d;
- GStatBuf st;
+ GDir *dp;
+ const gchar *d;
+ GError *error;
gint num;
FeedItem *item = NULL;
RFeedCtx *ctx;
ritem->items = NULL;
ritem->last_update = 0;
- if( (dp = opendir(path)) == NULL ) {
- FILE_OP_ERROR(path, "opendir");
+ if( (dp = g_dir_open(path, 0, &error)) == NULL ) {
+ FILE_OP_ERROR(path, "g_dir_open");
+ debug_print("g_dir_open on \"%s\" failed with error %d (%s)\n",
+ path, error->code, error->message);
g_free(path);
return;
}
- while( (d = readdir(dp)) != NULL ) {
+ while( (d = g_dir_read_name(dp)) != NULL ) {
if( claws_is_exiting() ) {
- closedir(dp);
+ g_dir_close(dp);
g_free(path);
return;
}
- if( d->d_name[0] != '.' && (num = to_number(d->d_name)) > 0 ) {
- fname = g_strdup_printf("%s%c%s", path, G_DIR_SEPARATOR, d->d_name);
- if( g_stat(fname, &st) < 0 ) {
- debug_print("RSSyl: couldn't stat() file '%s', ignoring it\n", fname);
- g_free(fname);
- continue;
- }
-
- if( !S_ISREG(st.st_mode)) {
+ if( d[0] != '.' && (num = to_number(d)) > 0 ) {
+ fname = g_strdup_printf("%s%c%s", path, G_DIR_SEPARATOR, d);
+ if (!g_file_test(fname, G_FILE_TEST_IS_REGULAR)) {
debug_print("RSSyl: not a regular file: '%s', ignoring it\n", fname);
g_free(fname);
continue;
}
- debug_print("RSSyl: starting to parse '%s'\n", d->d_name);
+ debug_print("RSSyl: starting to parse '%s'\n", d);
if( (item = rssyl_parse_folder_item_file(fname)) != NULL ) {
/* Find latest timestamp */
ctx = (RFeedCtx *)item->data;
}
}
- closedir(dp);
+ g_dir_close(dp);
g_free(path);
ritem->items = g_slist_reverse(ritem->items);
static void rssyl_get_last_num(Folder *folder, FolderItem *item)
{
gchar *path;
- DIR *dp;
- struct dirent *d;
+ const char *f;
+ GDir *dp;
+ GError *error;
gint max = 0;
gint num;
path = folder_item_get_path(item);
g_return_if_fail(path != NULL);
- if( (dp = opendir(path)) == NULL ) {
- FILE_OP_ERROR(item->path, "opendir");
+ if( (dp = g_dir_open(path, 0, &error)) == NULL ) {
+ FILE_OP_ERROR(item->path, "g_dir_open");
+ debug_print("g_dir_open() failed on \"%s\", error %d (%s).\n",
+ path, error->code, error->message);
g_free(path);
return;
}
g_free(path);
- while( (d = readdir(dp)) != NULL ) {
- if( (num = to_number(d->d_name)) > 0 && dirent_is_regular_file(d) ) {
+ while( (f = g_dir_read_name(dp)) != NULL) {
+ if ((num = to_number(f)) > 0 &&
+ g_file_test(f, G_FILE_TEST_IS_REGULAR)) {
if( max < num )
max = num;
}
}
- closedir(dp);
+ g_dir_close(dp);
debug_print("Last number in dir %s = %d\n", item->path, max);
item->last_num = max;
MsgNumberList **list, gboolean *old_uids_valid)
{
gchar *path;
- DIR *dp;
- struct dirent *d;
+ GDir *dp;
+ const gchar *d;
+ GError *error;
gint num, nummsgs = 0;
g_return_val_if_fail(item != NULL, -1);
path = folder_item_get_path(item);
g_return_val_if_fail(path != NULL, -1);
- if( (dp = opendir(path)) == NULL ) {
+ if( (dp = g_dir_open(path, 0, &error)) == NULL ) {
FILE_OP_ERROR(item->path, "opendir");
+ debug_print("g_dir_open() failed on \"%s\", error %d (%s).\n",
+ path, error->code, error->message);
g_free(path);
return -1;
}
g_free(path);
- while( (d = readdir(dp)) != NULL ) {
- if( (num = to_number(d->d_name)) > 0 ) {
+ while( (d = g_dir_read_name(dp)) != NULL ) {
+ if( (num = to_number(d)) > 0 ) {
*list = g_slist_prepend(*list, GINT_TO_POINTER(num));
nummsgs++;
}
}
-
- closedir(dp);
+ g_dir_close(dp);
debug_print("RSSyl: get_num_list: returning %d\n", nummsgs);
FolderItem *item = &ritem->item;
FeedItem *fi = NULL;
RFetchCtx *ctx = NULL;
- DIR *dp;
- struct dirent *d;
+ GDir *dp;
+ const gchar *d;
+ GError *error;
gint num;
gchar *path, *msg, *fname;
MainWindow *mainwin = mainwindow_get_mainwindow();
debug_print("RSSyl: starting to parse comments, path is '%s'\n", path);
- if( (dp = opendir(path)) == NULL ) {
- FILE_OP_ERROR(item->path, "opendir");
+ if( (dp = g_dir_open(path, 0, &error)) == NULL ) {
+ FILE_OP_ERROR(item->path, "g_dir_open");
+ debug_print("g_dir_open on \"%s\" failed with error %d (%s)\n",
+ path, error->code, error->message);
+ g_error_free(error);
g_free(path);
return;
}
ritem->fetching_comments = TRUE;
- while( (d = readdir(dp)) != NULL ) {
+ while( (d = g_dir_read_name(dp)) != NULL ) {
if (claws_is_exiting()) {
- closedir(dp);
+ g_dir_close(dp);
g_free(path);
debug_print("RSSyl: bailing out, app is exiting\n");
return;
}
-#ifdef G_OS_WIN32
- if( (num = to_number(d->d_name)) > 0) {
-#else
- if( (num = to_number(d->d_name)) > 0 && d->d_type == DT_REG ) {
-#endif
- debug_print("RSSyl: starting to parse '%s'\n", d->d_name);
+ if( (num = to_number(d)) > 0) {
+ fname = g_strdup_printf("%s%c%s", path, G_DIR_SEPARATOR, d);
+ if (!g_file_test(fname, G_FILE_TEST_IS_REGULAR))
+ continue;
+
+ debug_print("RSSyl: starting to parse '%s'\n", d);
- fname = g_strdup_printf("%s%c%s", path, G_DIR_SEPARATOR, d->d_name);
if( (fi = rssyl_parse_folder_item_file(fname)) != NULL ) {
if( feed_item_get_comments_url(fi) && feed_item_get_id(fi) &&
(ritem->fetch_comments_max_age == -1 ||
}
}
- closedir(dp);
+ g_dir_close(dp);
g_free(path);
ritem->fetching_comments = FALSE;