IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35878


Ignore:
Timestamp:
Aug 2, 2013, 11:12:17 AM (13 years ago)
Author:
eugene
Message:

add age restriction option for purge-temp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130711/Ohana/src/opihi/dvo/hosts.c

    r35757 r35878  
    1212    gprint (GP_ERR, "  commands:\n");
    1313    gprint (GP_ERR, "    purge-temp : delete all tempfiles for this shell\n");
    14     gprint (GP_ERR, "               : [-old-pid] [-all-pid] [-v] [-verbose] [-commit] [-type type]\n");
     14    gprint (GP_ERR, "               : [-old-pid] [-all-pid] [-v] [-verbose] [-commit] [-type type] [-age hours]\n");
    1515    gprint (GP_ERR, "    get-results : determine name of RESULTS file\n");
    1616    return FALSE;
     
    3333    }
    3434   
     35    struct timeval now;
     36    gettimeofday (&now, NULL);
     37
     38    float AGE = 0;
     39    int NOW = now.tv_sec;
     40    if ((N = get_argument (argc, argv, "-age"))) {
     41      remove_argument (N, &argc, argv);
     42      AGE = atof(argv[N]);
     43      remove_argument (N, &argc, argv);
     44    }
     45
    3546    int VERBOSE = FALSE;
    3647    if ((N = get_argument (argc, argv, "-v"))) {
     
    121132      glob (name, 0, NULL, &pglob);
    122133      int j;
     134      struct stat filestats;
    123135      for (j = 0; j < pglob.gl_pathc; j++) {
     136        if (AGE > 0) {
     137          if (stat(pglob.gl_pathv[j], &filestats)) {
     138            gprint (GP_ERR, "failed to get stats for %s\n", pglob.gl_pathv[j]);
     139            continue;
     140          }
     141          float myAge = (NOW - filestats.st_mtime) / 3600.0;
     142          if (myAge < AGE) continue;
     143        }
    124144        if (VERBOSE) gprint (GP_ERR, "unlink %s\n", pglob.gl_pathv[j]);
    125145        if (!DRYRUN) unlink (pglob.gl_pathv[j]);
Note: See TracChangeset for help on using the changeset viewer.