aboutsummaryrefslogtreecommitdiff
path: root/libsylph/mh.c
diff options
context:
space:
mode:
authorHiro <Hiro@ee746299-78ed-0310-b773-934348b2243d>2006-06-23 14:20:27 +0000
committerHiro <Hiro@ee746299-78ed-0310-b773-934348b2243d>2006-06-23 14:20:27 +0000
commita9fbc74b0b3ab2eee9981688755fabceb06520d7 (patch)
treecded7c81214ad1cd27cd47f1af58b3d3aa2f1620 /libsylph/mh.c
parente95849793470332ec48a4e26069a5b4b3fcd84ad (diff)
win32: optimized scanning of directory.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1084 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph/mh.c')
-rw-r--r--libsylph/mh.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/libsylph/mh.c b/libsylph/mh.c
index 99e87cb6..67c87595 100644
--- a/libsylph/mh.c
+++ b/libsylph/mh.c
@@ -32,6 +32,10 @@
#include <string.h>
#include <errno.h>
+#ifdef G_OS_WIN32
+# include <windows.h>
+#endif
+
#undef MEASURE_TIME
#include "folder.h"
@@ -740,8 +744,9 @@ static gint mh_scan_folder_full(Folder *folder, FolderItem *item,
{
gchar *path;
#ifdef G_OS_WIN32
- GDir *dir;
- const gchar *dir_name;
+ WIN32_FIND_DATAW wfd;
+ HANDLE hfind;
+ gchar *dir_name;
#else
DIR *dp;
struct dirent *d;
@@ -763,7 +768,7 @@ static gint mh_scan_folder_full(Folder *folder, FolderItem *item,
g_free(path);
#ifdef G_OS_WIN32
- if ((dir = g_dir_open(".", 0, NULL)) == NULL) {
+ if ((hfind = FindFirstFileW(L"*", &wfd)) == INVALID_HANDLE_VALUE) {
g_warning("failed to open directory\n");
#else
if ((dp = opendir(".")) == NULL) {
@@ -776,16 +781,23 @@ static gint mh_scan_folder_full(Folder *folder, FolderItem *item,
folder->ui_func(folder, item, folder->ui_func_data);
#ifdef G_OS_WIN32
- while ((dir_name = g_dir_read_name(dir)) != NULL) {
- if ((num = to_number(dir_name)) > 0 &&
- g_file_test(dir_name, G_FILE_TEST_IS_REGULAR)) {
- n_msg++;
- if (max < num)
- max = num;
+ do {
+ if ((wfd.dwFileAttributes &
+ (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE)) == 0) {
+ dir_name = g_utf16_to_utf8(wfd.cFileName, -1,
+ NULL, NULL, NULL);
+ if (dir_name) {
+ if ((num = to_number(dir_name)) > 0) {
+ n_msg++;
+ if (max < num)
+ max = num;
+ }
+ g_free(dir_name);
+ }
}
- }
+ } while (FindNextFileW(hfind, &wfd));
- g_dir_close(dir);
+ FindClose(hfind);
#else
while ((d = readdir(dp)) != NULL) {
if ((num = to_number(d->d_name)) > 0 &&
@@ -821,7 +833,7 @@ static gint mh_scan_folder_full(Folder *folder, FolderItem *item,
item->updated = TRUE;
item->mtime = 0;
- debug_print(_("Last number in dir %s = %d\n"), item->path, max);
+ debug_print("Last number in dir %s = %d\n", item->path, max);
item->last_num = max;
return 0;