IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 6, 2008, 2:09:40 PM (18 years ago)
Author:
Paul Price
Message:

Adding function to activate single file out of a list.

File:
1 edited

Legend:

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

    r16257 r16344  
    914914// set the state of the specified pmFPAfile to active (state == true) or inactive
    915915// if name is NULL, set the state for all pmFPAfiles
    916 bool pmFPAfileActivate (psMetadata *files, bool state, char *name)
     916bool pmFPAfileActivate (psMetadata *files, bool state, const char *name)
    917917{
    918918    PS_ASSERT_PTR_NON_NULL(files, false);
     
    963963    return true;
    964964}
     965
     966
     967pmFPAfile *pmFPAfileActivateSingle(psMetadata *files, bool state, const char *name, int num)
     968{
     969    PS_ASSERT_PTR_NON_NULL(files, NULL);
     970    PS_ASSERT_STRING_NON_EMPTY(name, NULL);
     971    PS_ASSERT_INT_NONNEGATIVE(num, NULL);
     972
     973    psString regex = NULL;              // Regular expression for psMetadataIteratorAlloc
     974    psStringAppend(&regex, "^%s$", name);
     975
     976    int i = 0;                          // Counter
     977    psMetadataItem *item = NULL;        // Item from iteration
     978    psMetadataIterator *iter = psMetadataIteratorAlloc(files, PS_LIST_HEAD, regex); // Iterator
     979    psFree(regex);
     980    while ((item = psMetadataGetAndIncrement(iter))) {
     981        if (i++ == num) {
     982            pmFPAfile *file = item->data.V; // File of interest
     983            if (state) {
     984                file->state &= PS_NOT_U8(PM_FPA_STATE_INACTIVE);
     985            } else {
     986                file->state |= PM_FPA_STATE_INACTIVE;
     987            }
     988            psFree(iter);
     989            return file;
     990        }
     991    }
     992    psFree(iter);
     993    return NULL;
     994}
Note: See TracChangeset for help on using the changeset viewer.