IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23244


Ignore:
Timestamp:
Mar 10, 2009, 12:29:41 PM (17 years ago)
Author:
Paul Price
Message:

Add list of files read/written to configuration.

Location:
trunk/psModules/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAfileIO.c

    r21363 r23244  
    2222#include "pmFPARead.h"
    2323#include "pmFPAWrite.h"
    24 #include "pmFPAfileIO.h"
    2524#include "pmFPAfileFitsIO.h"
    2625#include "pmSpan.h"
     
    4443#include "pmSubtractionIO.h"
    4544#include "pmConcepts.h"
     45#include "pmConfigRun.h"
     46
     47#include "pmFPAfileIO.h"
    4648
    4749// attempt create, read, write, close, or free pmFPAfiles available in files files are
     
    164166    }
    165167
     168    if (!pmConfigRunFileAdd(config, file)) {
     169        psError(PS_ERR_UNKNOWN, false, "Unable to add file to run-time information");
     170        return false;
     171    }
     172
    166173    // select a reading method
    167174    bool status = true;
     
    412419            return false;
    413420        }
     421    }
     422
     423    if (!pmConfigRunFileAdd(config, file)) {
     424        psError(PS_ERR_UNKNOWN, false, "Unable to add file to run-time information");
     425        return false;
    414426    }
    415427
  • trunk/psModules/src/config/pmConfigRun.c

    r23243 r23244  
    44
    55#include <stdio.h>
     6#include <string.h>
    67#include <pslib.h>
    78
     
    2526        elem = psMetadataAlloc();
    2627        psMetadataAddMetadata(md, PS_LIST_HEAD, name, 0, comment, elem);
     28        psFree(elem);                   // Drop reference
    2729    }
    2830    return elem;
     
    4850    psAssert(files, "Require list of files");
    4951
    50     return psMetadataAddStr(files, PS_LIST_TAIL, file->name, PS_META_DUPLICATE_OK, NULL, file->filename);
     52    const char *name = file->name;      // Name of symbolic file
     53    const char *value = file->filename; // Value of symbolic file: the file name
     54
     55    psString regex = NULL;              // Regular expression for iteration
     56    psStringAppend(&regex, "^%s$", name);
     57    psMetadataIterator *iter = psMetadataIteratorAlloc(files, PS_LIST_HEAD, regex);
     58    psFree(regex);
     59    psMetadataItem *item;               // Item from iteration
     60    while ((item = psMetadataGetAndIncrement(iter))) {
     61        psAssert(item->type == PS_DATA_STRING, "We only put STRING types here.");
     62        if (strcmp(item->data.str, value) == 0) {
     63            // It's already present
     64            psFree(iter);
     65            return true;
     66        }
     67    }
     68    psFree(iter);
     69
     70    return psMetadataAddStr(files, PS_LIST_TAIL, name, PS_META_DUPLICATE_OK, NULL, value);
    5171}
    5272
Note: See TracChangeset for help on using the changeset viewer.