[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]
[MD:567]w32-get-true-file-link-count (Re: [Mew-Win32 00334] Re: mew-folder-list)
- X-ml-count: 567
- Subject: [MD:567]w32-get-true-file-link-count (Re: [Mew-Win32 00334] Re: mew-folder-list)
- From: "YAMAGUCHI, Shuhei" <yamagus@xxxxxxxxxxxxxxxxxx>
- Date: Sun, 08 Mar 1998 01:46:44 +0900 (JST)
- X-mailer: Mew version 1.93b23 on Emacs 20.2 / Mule 3.0 (MOMIJINOGA)
やまぐち@ねっとらぴゅたの住人、です。
#もとネタは、Mew-Win32 MLです。
>>> In article <uk9ac6ezr.fsf@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
>>> Miyashita Hisashi(宮下 尚:HIMI) <himi@xxxxxxxxxxxxxxxxxxxxxxxxx> writes:
himi> あのー、とってもいいにくいんですが、;_;
himi>
himi> w32-get-true-file-link-count's value is
himi> 100
himi>
himi> Documentation:
himi> nil means file-attributes does not check a link count of directory.
himi> If this variable is set a number, file-attributes count subdirectories
himi> until checks at least its number of entries.
himi> t means file-attributes count subdirectories until a last entry.
himi>
himi> すんません。というわけで、ディフォルトは100個までで、サボってます。;_;
himi> w32-get-true-file-link-countをtにして、やってみてください。
himi>
himi> ## だって、NetBIOS Over TCP/IPによるSMB共有だとFindNextFileが遅くて
himi> ## しょうがないんです。(NT + NTFSだとフィルタできますが;_;)
現状のような制限だけじゃなく、指定した数のディレクトリを見つけた時点で
カウントをやめるような制限もあるとうれしいなぁと思って、とうとう(^^;)
プリミティブ関数にも手を出してみました。
#英語をまともに書く自信がないのでdoc-stringには手をつけてません。 ^^;
w32-get-true-file-link-countにconsで指定された時に、現状と振る舞いが変
わります。
carは(t,nilを含めて)今まで通りのチェックする最大ファイル数で、cdrはカ
ウントする最大サブディレクトリ数です。
どちらかの制限にひっかかった時点で返ります。
file-attributesをディレクトリ再帰目的のみで用いる場合、(t . 3)を指定し
ておけば、確実に、かつ、ある程度速く処理が可能になると思います。
でわでわ
--
yamagus@xxxxxxxxxxxxxxxxxx / やまぐち@ねっとらぴゅたの住人
yamagus@xxxxxxxxxxx / 山口 修平
PGP-Fingerprint: 25 0F 6F E1 57 AD 56 08 3A BC D0 9B 48 AF 31 7A
#別の変数に指定するようにしたほうがいいような気もしないでもないですが、
#とりあえずサンプル実装ということで。 ^^;
##それらしい変数名がうかばなかったという説あり。 ^^;;;
--- w32.c.orig Sun Feb 08 19:54:25 1998
+++ w32.c Sat Mar 07 13:55:11 1998
@@ -1991,7 +1991,7 @@
int
file_attributes_stat (const char *path, struct stat * buf)
{
- int num, len, ret, max;
+ int num, len, ret, max, min;
HANDLE hf;
WIN32_FIND_DATA w32fd;
char name[MAX_PATH];
@@ -2018,14 +2018,30 @@
name[len + 2] = '\0';
}
+ max = min = -1;
if (NUMBERP (Vw32_get_true_file_link_count))
{
max = XINT (Vw32_get_true_file_link_count);
if (max <= 0)
- return ret;
+ return ret;
+ }
+ else if (CONSP (Vw32_get_true_file_link_count))
+ {
+ if (NILP (XCONS (Vw32_get_true_file_link_count)->car))
+ return ret;
+ else if (NUMBERP (XCONS (Vw32_get_true_file_link_count)->car))
+ {
+ max = XCONS (Vw32_get_true_file_link_count)->car;
+ if (max <= 0)
+ return ret;
+ }
+ if (NUMBERP (XCONS (Vw32_get_true_file_link_count)->cdr))
+ {
+ min = XCONS (Vw32_get_true_file_link_count)->cdr;
+ if (min <= 0)
+ min = -1;
+ }
}
- else
- max = -1;
num = 0;
hf = FindFirstFile (name, &w32fd);
@@ -2035,7 +2051,10 @@
do {
if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- num++;
+ {
+ num++;
+ if (min > 0 && num >= min) break;
+ }
if (max > 0) max--;
else if (max == 0) break;
} while (FindNextFile (hf, &w32fd));