AltraMayor / AltraMayor/f3

Add leading 0s to align columns

Ouverte
#112 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Enhancement Good first issue
Langage dominant
C
Étoiles
3.4k
Forks
177
Merge moyen
2 j 15 h
PR mergées (30 j)
2

Description

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](https://github.com/AltraMayor/f3/blob/master/f3write.c#L597), then pass it to [this one](https://github.com/AltraMayor/f3/blob/master/f3write.c#L506) and [this one](https://github.com/AltraMayor/f3/blob/742f4e613f1fa923216394b6202fb389cb242de8/utils.c#L54), 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.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.