Logo Search packages:      
Sourcecode: tardy version File versions  Download package

void filenamelist_filter_progress::show_middle_status (  )  [private]

The spinner method is used to show how far along with readin gthe file list we are. This indirectly indicates how long it will be before we finish (ETA).

Definition at line 159 of file progress.cc.

References list, next_time, position, show, size_position, size_total, spinner(), and start_time.

Referenced by read_one_line().

{
      if (!show)
            return;
      time_t now;
      time(&now);
      if (now < next_time)
            return;
      next_time = now + 1;

      char buffer[80];
      char *bp = buffer;
      *bp++ = '\r';

      snprintf(bp, buffer + sizeof(buffer) - bp, "%s of ",
            format_size(position));
      bp += strlen(bp);
      snprintf(bp, buffer + sizeof(buffer) - bp, "%s files, ",
            format_size(list.size()));
      bp += strlen(bp);

      snprintf(bp, buffer + sizeof(buffer) - bp, "%sB of ",
            format_size(size_position));
      bp += strlen(bp);
      snprintf(bp, buffer + sizeof(buffer) - bp, "%sB, ",
            format_size(size_total));
      bp += strlen(bp);

      time_t elapsed = now - start_time;
      if (elapsed > 5 && size_total)
      {
          long long rate = size_position / elapsed;
          snprintf(bp, buffer + sizeof(buffer) - bp, "%sB/sec, ",
            format_size(rate));
          bp += strlen(bp);

          double frac = (double)size_position / (double)size_total;
          time_t total_time = time_t(elapsed / frac);
          time_t remaining_time = total_time - elapsed;
          snprintf(bp, buffer + sizeof(buffer) - bp, "ETA %s ",
            format_time(remaining_time));
          bp += strlen(bp);
      }

      snprintf(bp, buffer + sizeof(buffer) - bp, "%c ", spinner());
      ::write(2, buffer, strlen(buffer));
}


Generated by  Doxygen 1.6.0   Back to index