1.1 --- a/fsaccess/op_list_objects.c Thu Jan 11 19:24:44 2024 +0100
1.2 +++ b/fsaccess/op_list_objects.c Thu Jan 11 19:25:29 2024 +0100
1.3 @@ -107,28 +107,42 @@
1.4 return 0;
1.5 }
1.6
1.7 +/* List an object in the filesystem image. */
1.8 +
1.9 +static int list_object(const char *path)
1.10 +{
1.11 + /* Emit each object's name. */
1.12 +
1.13 + puts(path);
1.14 +
1.15 + /* List individual files or directories. */
1.16 +
1.17 + if (_list_object(path))
1.18 + {
1.19 + fprintf(stderr, "Failed to list object: %s\n", path);
1.20 + return 1;
1.21 + }
1.22 +
1.23 + return 0;
1.24 +}
1.25 +
1.26 /* List objects in the filesystem image. */
1.27
1.28 int list_objects(int argc, char *argv[])
1.29 {
1.30 int i;
1.31 - char *path;
1.32 +
1.33 + /* List the top level without any argument. */
1.34 +
1.35 + if (!argc)
1.36 + return list_object("");
1.37 +
1.38 + /* Otherwise, list all specified objects. */
1.39
1.40 for (i = 0; i < argc; i++)
1.41 {
1.42 - path = argv[i];
1.43 -
1.44 - /* Emit each object. */
1.45 -
1.46 - puts(path);
1.47 -
1.48 - /* List individual files or directories. */
1.49 -
1.50 - if (_list_object(path))
1.51 - {
1.52 - fprintf(stderr, "Failed to list object: %s\n", path);
1.53 + if (list_object(argv[i]))
1.54 return 1;
1.55 - }
1.56 }
1.57
1.58 return 0;