Add create command

This commit is contained in:
Fabio Scotto di Santolo
2026-08-01 13:58:19 +02:00
parent 462aa6e5bf
commit 3eae528f54
9 changed files with 176 additions and 51 deletions

View File

@@ -1,16 +1,9 @@
#define _XOPEN_SOURCE 500
#include "scan.h"
#include "utility.h"
#include "walk.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef PATH_MAX
static long pathmax = PATH_MAX;
#else
static long pathmax = 1024;
#endif
static int print_file(const char *file, void *context) {
(void)context;
printf("[%s]\n", file);
@@ -21,12 +14,9 @@ static int print_file(const char *file, void *context) {
int scan(const char *directory) {
if (directory == NULL || strlen(directory) == 0)
return -1;
char path[pathmax];
const char *dir = NULL;
if ((dir = realpath(directory, path)) == NULL) {
perror("realpath");
return -1;
}
const char *dir = resolve_path(directory);
if (dir == NULL)
return -1;
return walk(dir, print_file, NULL);
}