Files
scan/src/main.c
T

62 lines
1.3 KiB
C

// external dependencies
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <argp.h>
#include <dirent.h>
#include <errno.h>
#include <linux/limits.h>
// internal dependencies
#include "log.h"
#include "arguments.h"
// program logic
int main( int argc, char** argv )
{
arguments_t args;
initialise_args( &args );
parse_args( argc, argv, &args );
char argument_directory[ PATH_MAX ] = ".";
DIR* directory = opendir( argument_directory );
struct dirent* entry;
if ( !directory )
{
if ( ENOENT == errno )
log_error( "no directory `%s`", argument_directory );
else
log_error( "failed to open directory `%s`", argument_directory );
return -1;
}
while ( NULL != ( entry = readdir( directory ) ) )
{
if ( !args.show_all && ( !strncmp( entry->d_name, ".", 1) || !strncmp( entry->d_name, "..", 2 ) ) )
{
continue;
}
log_info( "%s", entry->d_name );
}
closedir( directory );
// char current_directory[ PATH_MAX ];
//
// if ( NULL != getcwd( &current_directory[0], PATH_MAX ) )
// {
// log_info( "current directory: %s", current_directory );
// }
// else
// {
// log_error( "failed to get the current directory" );
// return -1;
// }
return 0;
}