]> git.tue.mpg.de Git - paraslash.git/commitdiff
Add new ls option -d.
authorAndre Noll <maan@systemlinux.org>
Sat, 13 Jun 2009 11:53:42 +0000 (13:53 +0200)
committerAndre Noll <maan@systemlinux.org>
Sat, 13 Jun 2009 11:53:42 +0000 (13:53 +0200)
This is useful for the conversion script that transforms the afs
database to the 0.4 format.

NEWS
afs.cmd
aft.c

diff --git a/NEWS b/NEWS
index 20e5105ffa763a873f31e63c2c1c1644caf67991..4d775ecf078d12f723300278a25aedcdd73ad988 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ NEWS
        - improved signal handling
        - variable fec output buffer size
        - --log_color actually works
+       - new ls option: -d (print dates as seconds after the epoch)
 
 -----------------------------------------
 0.3.4 (2009-05-07) "elliptic inheritance"
diff --git a/afs.cmd b/afs.cmd
index da4b3f86030a299e477093de629595849b2b0173..0af4511302aa20a220907e79a35be20df04a2700 100644 (file)
--- a/afs.cmd
+++ b/afs.cmd
@@ -41,7 +41,7 @@ H: only the tables given by table_name... are created.
 N: ls
 P: AFS_READ
 D: List audio files.
-U: ls [-l[s|l|v|m]] -p -a -r -s{p|s|l|n|f|c|i|y|b|d|a} [pattern...]
+U: ls [-l[s|l|v|m]] [-p] [-a] [-r] [-d] [-s{p|s|l|n|f|c|i|y|b|d|a}] [pattern...]
 H: Print a list of all audio files matching pattern.
 H:
 H: Options:
@@ -66,6 +66,8 @@ H:    playlist.
 H:
 H: -r  Reverse sort order.
 H:
+H: -d  Print dates as seconds after the epoch.
+H:
 H: -s  Change sort order. Defaults to alphabetical path sort if not given.
 H:
 H:             -sp:  sort by path.
diff --git a/aft.c b/aft.c
index 995c7552129512c6e2dc6228c165779c9e7979a0..20fa3a96a4ccf1139d6d369ae8ff5764103e7822 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -74,6 +74,8 @@ enum ls_flags {
        LS_FLAG_ADMISSIBLE_ONLY = 2,
        /** -r */
        LS_FLAG_REVERSE = 4,
+       /** -d */
+       LS_FLAG_UNIXDATE = 8,
 };
 
 /**
@@ -800,10 +802,15 @@ static int print_list_item(struct ls_data *d, struct ls_options *opts,
                goto out;
        }
        get_attribute_bitmap(&afsi->attributes, att_buf);
-       ret = get_local_time(&afsi->last_played, last_played_time,
-               sizeof(last_played_time), current_time, opts->mode);
-       if (ret < 0)
-               goto out;
+       if (opts->flags & LS_FLAG_UNIXDATE)
+               sprintf(last_played_time, "%llu",
+                       (long long unsigned)afsi->last_played);
+       else {
+               ret = get_local_time(&afsi->last_played, last_played_time,
+                       sizeof(last_played_time), current_time, opts->mode);
+               if (ret < 0)
+                       goto out;
+       }
        get_duration_buf(afhi->seconds_total, duration_buf, opts);
        if (have_score) {
                if (opts->mode == LS_MODE_LONG)
@@ -1458,6 +1465,10 @@ int com_ls(int fd, int argc, char * const * const argv)
                        flags |= LS_FLAG_REVERSE;
                        continue;
                }
+               if (!strcmp(arg, "-d")) {
+                       flags |= LS_FLAG_UNIXDATE;
+                       continue;
+               }
                if (!strncmp(arg, "-s", 2)) {
                        if (!*(arg + 2) || *(arg + 3))
                                return -E_AFT_SYNTAX;