diff --git a/CHANGELOG.md b/CHANGELOG.md index c51d40c..71be3bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * LinuxとBSD: 今から、静的リンクがデフォルトになりました(動的リンクには「make LDFLAGS=-lc」をご利用下さい) * 色コンフィグの追加 * カスタムロゴコンフィグの追加 +* モジュールのキャッシングの追加(それでスピードアップする) # 0.2.0 * Manjaroのロゴの追加 diff --git a/farfetch.1 b/farfetch.1 index fab65bd..e8b0333 100644 --- a/farfetch.1 +++ b/farfetch.1 @@ -8,6 +8,9 @@ farfetch - system info .PP システム情報 .TP +\fB\,r\fR +キャッシュから削除(Haiku以外) +.TP \fB\,s\fR 小さいロゴの表示 .TP @@ -16,3 +19,4 @@ farfetch - system info .SH AUTHORS .PP テクニカル諏訪子(開発者) +ハツラツ太郎(開発者) diff --git a/main.c b/main.c index 47bb455..169e907 100644 --- a/main.c +++ b/main.c @@ -25,13 +25,16 @@ #include "src/storage.h" #include "src/config.h" +#include "src/common.h" const char *sofname = "farfetch"; const char *version = "0.3.0"; #if defined(__linux__) || defined(__sun) -const char *avalopt = "ls"; -#else +const char *avalopt = "lrs"; +#elif defined(__HAIKU__) const char *avalopt = "s"; +#else +const char *avalopt = "rs"; #endif int opt; @@ -43,7 +46,7 @@ int iserr = 0; void usage() { #if defined(__linux__) || defined(__sun) - printf("%s-%s\nusage: %s [-s] [-l distro]\n", sofname, version, sofname); + printf("%s-%s\nusage: %s [-rs] [-l distro]\n", sofname, version, sofname); #else printf("%s-%s\nusage: %s [-%s]\n", sofname, version, sofname, avalopt); #endif @@ -55,6 +58,11 @@ void flags(int opt) { case 'l': islogo = 1; break; +#endif +#if !defined(__HAIKU__) + case 'r': + delete_cache(); + break; #endif case 's': issmall = 1; diff --git a/src/common.c b/src/common.c index 5070d6e..5514686 100644 --- a/src/common.c +++ b/src/common.c @@ -111,4 +111,14 @@ int to_cache(const char *file, const char *res) { return 0; } + +void delete_cache() { + struct stat st; + + if (stat("/tmp/farfetch/os", &st) == 0) remove("/tmp/farfetch/os"); + if (stat("/tmp/farfetch/host", &st) == 0) remove("/tmp/farfetch/host"); + if (stat("/tmp/farfetch/distro", &st) == 0) remove("/tmp/farfetch/distro"); + if (stat("/tmp/farfetch/cpu", &st) == 0) remove("/tmp/farfetch/cpu"); + if (stat("/tmp/farfetch/gpu", &st) == 0) remove("/tmp/farfetch/gpu"); +} #endif diff --git a/src/common.h b/src/common.h index bddbb8b..ba72d4f 100644 --- a/src/common.h +++ b/src/common.h @@ -6,6 +6,7 @@ const char *run_command_s(const char *command); #if !defined(__HAIKU__) const char *from_cache(const char *file); int to_cache(const char *file, const char *res); +void delete_cache(); #endif #endif