gboolean mh_scan_required(Folder *folder, FolderItem *item)
{
gchar *path;
- struct stat s;
+ GStatBuf s;
path = folder_item_get_path(item);
cm_return_val_if_fail(path != NULL, FALSE);
static void mh_get_last_num(Folder *folder, FolderItem *item)
{
gchar *path;
- DIR *dp;
- struct dirent *d;
+ GDir *dp;
+ const gchar *d;
+ GError *error = NULL;
gint max = 0;
gint num;
}
g_free(path);
- if ((dp = opendir(".")) == NULL) {
- FILE_OP_ERROR(item->path, "opendir");
+ if ((dp = g_dir_open(".", 0, &error)) == NULL) {
+ g_message("Couldn't open current directory: %s (%d).\n",
+ error->message, error->code);
+ g_error_free(error);
return;
}
- while ((d = readdir(dp)) != NULL) {
- if ((num = to_number(d->d_name)) > 0 &&
- dirent_is_regular_file(d)) {
+ while ((d = g_dir_read_name(dp)) != NULL) {
+ if ((num = to_number(d)) > 0 &&
+ g_file_test(d, G_FILE_TEST_IS_REGULAR)) {
if (max < num)
max = num;
}
if (num % 2000 == 0)
GTK_EVENTS_FLUSH();
}
- closedir(dp);
+ g_dir_close(dp);
debug_print("Last number in dir %s = %d\n", item->path?item->path:"(null)", max);
item->last_num = max;
{
gchar *path;
- DIR *dp;
- struct dirent *d;
+ GDir *dp;
+ const gchar *d;
+ GError *error = NULL;
gint num, nummsgs = 0;
cm_return_val_if_fail(item != NULL, -1);
}
g_free(path);
- if ((dp = opendir(".")) == NULL) {
- FILE_OP_ERROR(item->path, "opendir");
+ if ((dp = g_dir_open(".", 0, &error)) == NULL) {
+ g_message("Couldn't open current directory: %s (%d).\n",
+ error->message, error->code);
+ g_error_free(error);
return -1;
}
- 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);
mh_set_mtime(folder, item);
return nummsgs;
if (link(fileinfo->file, destfile) < 0) {
#endif
if (copy_file(fileinfo->file, destfile, TRUE) < 0) {
- g_warning(_("can't copy message %s to %s\n"),
+ g_warning("can't copy message %s to %s",
fileinfo->file, destfile);
g_free(destfile);
return -1;
cm_return_val_if_fail(msginfo != NULL, -1);
if (msginfo->folder == dest) {
- g_warning("the src folder is identical to the dest.\n");
+ g_warning("the src folder is identical to the dest.");
return -1;
}
}
if (relation) {
if (g_hash_table_lookup(relation, msginfo) != NULL)
- g_warning("already in : %p", msginfo);
+ g_warning("already in: %p", msginfo);
g_hash_table_insert(relation, msginfo, GINT_TO_POINTER(dest->last_num+1));
}
static gboolean mh_is_msg_changed(Folder *folder, FolderItem *item,
MsgInfo *msginfo)
{
- struct stat s;
+ GStatBuf s;
if (g_stat(itos(msginfo->msgnum), &s) < 0 ||
msginfo->size != s.st_size || (
{ \
if (!is_dir_exist(dir)) { \
if (is_file_exist(dir)) { \
- g_warning("File `%s' already exists.\n" \
+ g_warning("File '%s' already exists. " \
"Can't create folder.", dir); \
return -1; \
} \
MsgInfo *info = folder_item_get_msginfo(parent, to_number(name));
if (info != NULL) {
gboolean ok = mh_renumber_msg(info);
- procmsg_msginfo_free(info);
+ procmsg_msginfo_free(&info);
if (!ok) {
g_free(fullpath);
return NULL;
static gint mh_remove_folder(Folder *folder, FolderItem *item)
{
gchar *path;
+ gint ret;
cm_return_val_if_fail(folder != NULL, -1);
cm_return_val_if_fail(item != NULL, -1);
cm_return_val_if_fail(item->path != NULL, -1);
path = folder_item_get_path(item);
- if (remove_dir_recursive(path) < 0) {
- g_warning("can't remove directory `%s'\n", path);
+ if ((ret = remove_dir_recursive(path)) < 0) {
+ g_warning("can't remove directory '%s'", path);
g_free(path);
- return -1;
+ return ret;
}
g_free(path);
static void mh_scan_tree_recursive(FolderItem *item)
{
Folder *folder;
-#ifdef G_OS_WIN32
GDir *dir;
-#else
- DIR *dp;
- struct dirent *d;
-#endif
const gchar *dir_name;
- struct stat s;
gchar *real_path, *entry, *utf8entry, *utf8name;
gint n_msg = 0;
+ GError *error = NULL;
cm_return_if_fail(item != NULL);
cm_return_if_fail(item->folder != NULL);
folder = item->folder;
real_path = item->path ? mh_filename_from_utf8(item->path) : g_strdup(".");
-#ifdef G_OS_WIN32
- dir = g_dir_open(real_path, 0, NULL);
+ dir = g_dir_open(real_path, 0, &error);
if (!dir) {
- g_warning("failed to open directory: %s\n", real_path);
+ g_warning("failed to open directory '%s': %s (%d)",
+ real_path, error->message, error->code);
+ g_error_free(error);
g_free(real_path);
return;
}
-#else
- dp = opendir(real_path);
- if (!dp) {
- FILE_OP_ERROR(real_path, "opendir");
- return;
- }
-#endif
g_free(real_path);
debug_print("scanning %s ...\n",
if (folder->ui_func)
folder->ui_func(folder, item, folder->ui_func_data);
-#ifdef G_OS_WIN32
while ((dir_name = g_dir_read_name(dir)) != NULL) {
-#else
- while ((d = readdir(dp)) != NULL) {
- dir_name = d->d_name;
-#endif
if (dir_name[0] == '.') continue;
utf8name = mh_filename_to_utf8(dir_name);
utf8entry = g_strdup(utf8name);
entry = mh_filename_from_utf8(utf8entry);
- if (
-#if !defined(G_OS_WIN32) && defined(HAVE_DIRENT_D_TYPE)
- d->d_type == DT_DIR ||
- (d->d_type == DT_UNKNOWN &&
-#endif
- g_stat(entry, &s) == 0 && S_ISDIR(s.st_mode)
-#if !defined(G_OS_WIN32) && defined(HAVE_DIRENT_D_TYPE)
- )
-#endif
- ) {
+ if (g_file_test(entry, G_FILE_TEST_IS_DIR)) {
FolderItem *new_item = NULL;
GNode *node;
g_free(utf8name);
}
-#ifdef G_OS_WIN32
g_dir_close(dir);
-#else
- closedir(dp);
-#endif
mh_set_mtime(folder, item);
}
oldpathlen = strlen(oldpath);
if (strncmp(oldpath, item->path, oldpathlen) != 0) {
- g_warning("path doesn't match: %s, %s\n", oldpath, item->path);
+ g_warning("path doesn't match: %s, %s", oldpath, item->path);
return TRUE;
}
gchar *real_path = g_filename_from_utf8(path, -1, NULL, NULL, NULL);
if (!real_path) {
- g_warning("mh_filename_from_utf8: failed to convert character set\n");
+ g_warning("mh_filename_from_utf8: failed to convert character set");
real_path = g_strdup(path);
}
{
gchar *utf8path = g_filename_to_utf8(path, -1, NULL, NULL, NULL);
if (!utf8path) {
- g_warning("mh_filename_to_utf8: failed to convert character set\n");
+ g_warning("mh_filename_to_utf8: failed to convert character set");
utf8path = g_strdup(path);
}
static void mh_set_mtime(Folder *folder, FolderItem *item)
{
- struct stat s;
+ GStatBuf s;
gchar *path = folder_item_get_path(item);
cm_return_if_fail(path != NULL);