ちょっとしたコードの断片集
(2006-03-15 13:13:56 (水))
// 拡張子を".txt"の形式で渡すと // 関連する拡張子の中で代表的なものを返す。 // 未登録だった場合FALSEを返してextはそのまま。 // 例: GetRepresentExt(".h") ==> ".c" // 例: GetRepresentExt(".htm") ==> ".htm" // 例: GetRepresentExt(".html") ==> ".html" // 例: GetRepresentExt(".xyz") ==> ".xyz" BOOL GetRepresentExt(txstr ext) { BOOL ret = FALSE; txstr path; pathFullConfig(path, "txcfg.cfg"); TX *text = textopen(path); txstr find; sprintf(find, \"^Exts\:.*%s\W", ext); if(searchex(find, SEARCH_NOSENSECASE | SEARCH_REWZ)) { txstr line; getpara(line); regular(line, \"^Exts:\s+(\.\w+).*$", \"\1", 0); ext = line; ret = TRUE; } textclose(text); return ret; }