最新ルールに従う様に

このコミットが含まれているのは:
守矢諏訪子 2024-02-03 19:37:46 +09:00
コミット 0aaf5f12b2
1個のファイルの変更28行の追加28行の削除

ファイルの表示

@ -18,37 +18,37 @@ void listpass(char* basePath, int level) {
} }
while ((entry = readdir(dir)) != NULL) { while ((entry = readdir(dir)) != NULL) {
if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) { if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
char path[1000]; continue;
int needed = snprintf(path, sizeof(path), "%s/%s", basePath, entry->d_name); }
if (needed >= (int)sizeof(path) || needed < 0) {
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Error: Path is too long, or failed to getting lenth");
else perror("エラー:パスが長すぎる、又は長さを受取に失敗");
continue;
}
struct stat statbuf; char path[1000];
if (stat(path, &statbuf) == -1) { int needed = snprintf(path, sizeof(path), "%s/%s", basePath, entry->d_name);
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to reading file status"); if (needed >= (int)sizeof(path) || needed < 0) {
else perror("ファイル状況を読込に失敗"); if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Error: Path is too long, or failed to getting lenth");
continue; else perror("エラー:パスが長すぎる、又は長さを受取に失敗");
} continue;
}
for (int i = 0; i < level; i++) { struct stat statbuf;
printf(" "); if (stat(path, &statbuf) == -1) {
} if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to reading file status");
else perror("ファイル状況を読込に失敗");
continue;
}
if (S_ISDIR(statbuf.st_mode)) { for (int i = 0; i < level; i++) {
printf("|-- %s\n", entry->d_name); printf(" ");
listpass(path, level + 1); }
} else if (S_ISREG(statbuf.st_mode)) {
char* filename = entry->d_name; if (S_ISDIR(statbuf.st_mode)) {
char* ext = strstr(filename, ".gpg"); printf("|-- %s\n", entry->d_name);
if (ext) { listpass(path, level + 1);
*ext = '\0'; } else if (S_ISREG(statbuf.st_mode)) {
} char* filename = entry->d_name;
printf("|-- %s\n", filename); char* ext = strstr(filename, ".gpg");
} if (ext) *ext = '\0';
printf("|-- %s\n", filename);
} }
} }