mirror of
https://github.com/fscotto/fsnap.git
synced 2026-11-26 03:09:51 +00:00
Add create command
This commit is contained in:
18
src/scan.c
18
src/scan.c
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user