[PATCH evemu 3/3] evemu-record: if we have no events, delete the autorestarted file

Peter Hutterer peter.hutterer at who-t.net
Tue Mar 1 00:42:56 UTC 2016


On Mon, Feb 29, 2016 at 10:41:10AM +0100, Benjamin Tissoires wrote:
> On Fri, Feb 26, 2016 at 3:53 AM, Peter Hutterer
> <peter.hutterer at who-t.net> wrote:
> > The last file (when evemu-record was cancelled) remains.
> 
> I had to actually run the tool to understand this. We keep all the
> files that have events in it. Might be worth mentioning it, just to
> reassure the maintainer :)

isn't this what the subject line says? :) Anyway, I've reworded it.

> Anyway, thanks for the series. Please amend it and I'll push it.

thanks for the review. Updates series coming up.

Cheers,
   Peter

> >
> > Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> > ---
> >  tools/evemu-record.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/evemu-record.c b/tools/evemu-record.c
> > index 8a78cd1..4346bc9 100644
> > --- a/tools/evemu-record.c
> > +++ b/tools/evemu-record.c
> > @@ -146,6 +146,7 @@ static bool record_device(int fd, unsigned int timeout, const char *prefix)
> >  {
> >         char *filename = NULL;
> >         bool rc = false;
> > +       long ftell_start = 0 , ftell_end = 1;
> >
> >         assert(!autorestart || prefix != NULL);
> >
> > @@ -178,12 +179,15 @@ static bool record_device(int fd, unsigned int timeout, const char *prefix)
> >                 fprintf(output,  "################################\n");
> >                 fprintf(output,  "#      Waiting for events      #\n");
> >                 fprintf(output,  "################################\n");
> > -               if (autorestart)
> > +               if (autorestart) {
> >                         fprintf(output, "# Autorestart timeout: %d\n", timeout);
> > +                       ftell_start = ftell(output);
> > +               }
> >
> >                 if (evemu_record(output, fd, timeout)) {
> >                         fprintf(stderr, "error: could not record device\n");
> >                 } else if (autorestart) {
> > +                       ftell_end = ftell(output);
> >                         fprintf(output, "# Closing after %ds inactivity\n",
> >                                 timeout/1000);
> >                 }
> > @@ -192,6 +196,9 @@ static bool record_device(int fd, unsigned int timeout, const char *prefix)
> >                 if (output != stdout) {
> >                         fclose(output);
> >                         output = stdout;
> > +
> > +                       if (autorestart && ftell_start == ftell_end)
> > +                               unlink(filename);
> >                 }
> >         } while (autorestart);
> >
> > --
> > 2.5.0
> >
> > _______________________________________________
> > Input-tools mailing list
> > Input-tools at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/input-tools


More information about the Input-tools mailing list