Skip to content

Add leading 0s to align columns #112

Description

@matthieu-vergne

Hi,

I am just starting to use this tool on some SD cards. I think it could have a better display by adding leading zeros to the counter in file names.

Current state

Creating file 1.h2w ... OK!                           
Creating file 2.h2w ... OK!                           
Creating file 3.h2w ... OK!                           
Creating file 4.h2w ... OK!                           
Creating file 5.h2w ... OK!                           
Creating file 6.h2w ... OK!                           
Creating file 7.h2w ... OK!                           
Creating file 8.h2w ... OK!                           
Creating file 9.h2w ... OK!                           
Creating file 10.h2w ... OK!                           
Creating file 11.h2w ... OK!                           
Creating file 12.h2w ... OK!                           
Creating file 13.h2w ... OK!                           
Creating file 14.h2w ... OK!    

Expected state

Creating file 01.h2w ... OK!                           
Creating file 02.h2w ... OK!                           
Creating file 03.h2w ... OK!                           
Creating file 04.h2w ... OK!                           
Creating file 05.h2w ... OK!                           
Creating file 06.h2w ... OK!                           
Creating file 07.h2w ... OK!                           
Creating file 08.h2w ... OK!                           
Creating file 09.h2w ... OK!                           
Creating file 10.h2w ... OK!                           
Creating file 11.h2w ... OK!                           
Creating file 12.h2w ... OK!                           
Creating file 13.h2w ... OK!                           
Creating file 14.h2w ... OK!    

Motivations

The advantages would be small but appreciable:

  • the list of created files is more elegant because completely aligned
  • the list of read files is more elegant because completely aligned
  • it makes the report slightly easier to read because everything is aligned
  • the files on the drive are always properly ordered by name independently of the file system, since ASCII and natural ordering give the same order with leading zeros

I don't see any disadvantage beside the time spent programming it. I assume the additional computation is small enough to be irrelevant.

How to do it

I am not a C programmer, so I don't make a pull request, but I tried to figure out whether it was something easy to do before to suggest it. Since it seems so (see below), I think it would be cheap enough to motivate it.

I assume you can know the number of required digits through the decimal logarithm of the free space or something like that. So basically you could compute the number of required digits only once in this method, then pass it to this one and this one, then replace %li by %0xxli where xx is the number of digits received.

I did not touch C since years, so I hope it makes sense.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions