キャッシュから削除の関数

このコミットが含まれているのは:
守矢諏訪子 2024-08-16 01:17:52 +09:00
コミット 22062d76c6
5個のファイルの変更27行の追加3行の削除

ファイルの表示

@ -11,6 +11,7 @@
* LinuxとBSD: 今から、静的リンクがデフォルトになりました(動的リンクには「make LDFLAGS=-lc」をご利用下さい)
* 色コンフィグの追加
* カスタムロゴコンフィグの追加
* モジュールのキャッシングの追加(それでスピードアップする)
# 0.2.0
* Manjaroのロゴの追加

ファイルの表示

@ -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
テクニカル諏訪子(開発者)
ハツラツ太郎(開発者)

14
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;

ファイルの表示

@ -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

ファイルの表示

@ -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