config config config

This commit is contained in:
root committed 2026-10-06 22:23:35 +02:00
1 parent 8ed2407463
commit bb0072a6f6
4 files changed
+62 -50

No files matched your search

+8 -4
View File
@@ -15,13 +15,17 @@ void format_clear( void )
void format_set_style( const style_t* const styles, uint8_t number )
{
if ( NUMBER_STYLES < number )
return;
if ( NUMBER_STYLES < number ) return;
if ( style_none == styles[ 0 ] ) return;
fprintf( stdout, SEQUENCE_PREFIX );
for ( int n = 0; n < number; n++ )
{
style_t style = styles[ n ];
if ( style_none <= style )
continue;
if ( n >= number - 1 )
{
fprintf( stdout, "%d", STYLE_SET[ style ] );
@@ -36,8 +40,8 @@ void format_set_style( const style_t* const styles, uint8_t number )
void format_reset_style( const style_t* const styles, uint8_t number )
{
if ( NUMBER_STYLES < number )
return;
if ( NUMBER_STYLES < number ) return;
if ( style_none == styles[ 0 ] ) return;
fprintf( stdout, SEQUENCE_PREFIX );
for ( int n = 0; n < number; n++ )
+47 -43
View File
@@ -335,25 +335,16 @@ int display_directory_contents(
}
( void )permissions_to_string(
args,
entry->stats.st_mode,
file_permissions
);
args,
entry->stats.st_mode,
file_permissions
);
size_to_string( entry, &file_size[ 0 ], LENGTH_SIZE );
if ( !args->tree_view )
{
log_info(
"%c%s%s %s",
file_type,
file_permissions,
file_size,
entry->name
);
}
else
if ( args->tree_view )
{
char tree[ NAME_MAX ] = "";
for ( size_t k = 0; k < recursion_level; k++ )
{
if ( !( is_last & 1 << k ) )
@@ -381,41 +372,54 @@ int display_directory_contents(
tree[ 4 * recursion_level + 3 ] = ' ';
fprintf( stdout, "%s", tree );
}
if ( entry->type == type_directory )
{
format_set_style( directory_style, DIR_STYLE_NUM );
format_set_fg_colour( directory_colour );
}
fprintf( stdout, "%s", entry->name );
if ( entry->type == type_directory )
{
format_reset_style( directory_style, DIR_STYLE_NUM );
format_clear_fg_colour();
}
fprintf( stdout, "\n" );
if ( entry->type == type_directory )
{
format_set_style( directory_style, DIR_STYLE_NUM );
format_set_fg_colour( directory_colour );
}
fprintf( stdout, "%s", entry->name );
if ( entry->type == type_directory )
{
format_reset_style( directory_style, DIR_STYLE_NUM );
format_clear_fg_colour();
}
fprintf( stdout, "\n" );
if ( recursion_level < args->depth
&& entry->type == type_directory )
// if ( !args->tree_view )
// {
// log_info(
// "%c%s%s %s",
// file_type,
// file_permissions,
// file_size,
// entry->name
// );
// }
// else
// {
if ( recursion_level < args->depth
&& entry->type == type_directory )
{
DIR* subdirectory = opendir(entry->name);
if ( !subdirectory )
{
DIR* subdirectory = opendir(entry->name);
if ( !subdirectory )
{
log_error( "failed to open directory `%s`", entry->name );
}
else
{
chdir( entry->name );
// TODO: handle return code
display_directory_contents(
log_error( "failed to open directory `%s`", entry->name );
}
else
{
chdir( entry->name );
// TODO: handle return code
display_directory_contents(
args,
subdirectory,
recursion_level + 1,
is_last | (size_t)( num_entries == n + 1 ) << recursion_level
);
closedir( subdirectory );
chdir( ".." );
}
);
closedir( subdirectory );
chdir( ".." );
}
}
}