[sylpheed-jp:10654] Re: 数字フォルダ名の作成

"M.H" <[email protected]>
Newsgroups gmane.mail.sylpheed.general.japanese
Message-ID <[email protected]>
こんばんは、M.H です。

今更ですが…^^;

> > sylpheed はシンプルなところが良いと思っているユーザーも
> > 多いのではないでしょうか。
> 
>  私の提案は GUI 的なシンプルさを犠牲にするものとは考えていません。
> 

結局は作者の方がやりたいようにやるのが一番だと思っていますが、
GUI的なシンプルさのために、構造がシンプルじゃなくなるのは、
それをメンテナンスしていくために、
今後ますますシンプルじゃなくなる可能性があるので、
止めた方がいいような気がします。

今までも数字名のフォルダは絶対に作れなかった訳じゃなく、
作ったとしても大きな問題は起きていなかったと覚しいので、
こんなショボいパッチでも十分じゃないかと考えたことがあるので、
一応、投げておきます。

-- この下から
--- libsylph/defs.h.mh_max_numberrc	2006-09-22 11:58:56.000000000 +0900
+++ libsylph/defs.h	2008-08-01 00:03:39.000000000 +0900
@@ -61,6 +61,7 @@
 #define DISPLAY_HEADER_RC	"dispheaderrc"
 #define MENU_RC			"menurc"
 #define ACTIONS_RC		"actionsrc"
+#define MH_MAX_NUMBER_RC	"mh_max_numberrc"
 #define COMMAND_HISTORY		"command_history"
 #define TEMPLATE_DIR		"templates"
 #define TMP_DIR			"tmp"
--- libsylph/mh.c.mh_max_numberrc	2007-05-10 13:04:34.000000000 +0900
+++ libsylph/mh.c	2008-08-01 00:03:39.000000000 +0900
@@ -876,6 +876,8 @@
 	gint num;
 	gint n_msg = 0;
 
+	FILE *fp;
+
 	g_return_val_if_fail(item != NULL, -1);
 
 	debug_print("mh_scan_folder(): Scanning %s ...\n", item->path);
@@ -934,6 +936,16 @@
 	closedir(dp);
 #endif
 
+	if ((fp = g_fopen(g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+					MH_MAX_NUMBER_RC, NULL), "r")) != NULL) {
+		while ((fscanf(fp, "%d", &num)) > 0) {
+			debug_print("%s = %d\n", MH_MAX_NUMBER_RC, num);
+			if (max < num && num <= 100000000)
+				max = num;
+		}
+		fclose(fp);
+	}
+
 	if (n_msg == 0)
 		item->new = item->unread = item->total = 0;
 	else if (count_sum) {
-- この上まで

フォルダごとにファイル名を数値にした時の最大値を算出しているので、
その最大値を設定出来るようにして、
あらかじめ使いそうな数字は空けておくというものです。
# ごみ箱だけ動きが謎なんですが…

100000000 の制限を取っ払えば、漏れなく整数値オーバーフローの
テストも簡単に出来ます:-P

こんな考え方もアリかも程度の参考までに。

追伸:
知らなかったんですが、 + と @ はmhのfolderコマンドで使うので、
頭とかお尻にくっつけるのは避けた方がいいみたいです。

Good Night!
  -M.H
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.