summaryrefslogtreecommitdiff
path: root/list.c
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2023-11-13 04:44:12 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2023-11-13 04:44:12 +0100
commitab52e851c95ebe2fa1ee4c2a5dcbc826bbb41769 (patch)
treef35d388ba56304a1054399a27d03acbafa2d2828 /list.c
parentbfdf2f591ed5d767df60c5672b9d1ceb605764eb (diff)
downloadcrep-ab52e851c95ebe2fa1ee4c2a5dcbc826bbb41769.tar.gz
Move to tabs
Diffstat (limited to 'list.c')
-rw-r--r--list.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/list.c b/list.c
index ef2ba2e..0743543 100644
--- a/list.c
+++ b/list.c
@@ -7,58 +7,58 @@
#include "list.h"
void add_file_path(Node **head, char *file_path) {
- Node *new = (Node *)malloc(sizeof(Node));
- new->file_path = strdup(file_path);
- new->next = *head;
- *head = new;
+ Node *new = (Node *)malloc(sizeof(Node));
+ new->file_path = strdup(file_path);
+ new->next = *head;
+ *head = new;
}
void list_files_recursively(char *base_path, Node **head) {
- char path[1000];
- struct dirent *dp;
- DIR *dir = opendir(base_path);
+ char path[1000];
+ struct dirent *dp;
+ DIR *dir = opendir(base_path);
- if (!dir) return;
+ if (!dir) return;
- while ((dp = readdir(dir)) != NULL) {
- if (strcmp(dp->d_name, ".") != 0 && strcmp(dp->d_name, "..") != 0) {
- strcpy(path, base_path);
- strcat(path, "/");
- strcat(path, dp->d_name);
+ while ((dp = readdir(dir)) != NULL) {
+ if (strcmp(dp->d_name, ".") != 0 && strcmp(dp->d_name, "..") != 0) {
+ strcpy(path, base_path);
+ strcat(path, "/");
+ strcat(path, dp->d_name);
- struct stat statbuf;
- if (stat(path, &statbuf) != -1) {
- if (S_ISDIR(statbuf.st_mode)) {
- list_files_recursively(path, head);
- } else {
- add_file_path(head, path);
- }
- }
- }
- }
+ struct stat statbuf;
+ if (stat(path, &statbuf) != -1) {
+ if (S_ISDIR(statbuf.st_mode)) {
+ list_files_recursively(path, head);
+ } else {
+ add_file_path(head, path);
+ }
+ }
+ }
+ }
- closedir(dir);
+ closedir(dir);
}
void free_file_list(Node *head) {
- Node *tmp;
+ Node *tmp;
- while (head != NULL) {
- tmp = head;
- head = head->next;
- free(tmp->file_path);
- free(tmp);
- }
+ while (head != NULL) {
+ tmp = head;
+ head = head->next;
+ free(tmp->file_path);
+ free(tmp);
+ }
}
int size_of_file_list(Node *head) {
- int count = 0;
+ int count = 0;
- Node *current = head;
- while (current != NULL) {
- count++;
- current = current->next;
- }
+ Node *current = head;
+ while (current != NULL) {
+ count++;
+ current = current->next;
+ }
- return count;
+ return count;
}