Changeset 16744


Ignore:
Timestamp:
06/20/12 18:40:12 (12 years ago)
Author:
nit
Message:

[titan] fix mediadb scan

File:
1 edited

Legend:

Unmodified
Added
Removed
  • titan/titan/mediadb.h

    r16727 r16744  
    423423}
    424424
    425 //flag1 0: with lock
    426 //flag1 1: without lock
     425//flag 0: with lock
     426//flag 1: without lock
    427427struct mediadb* addmediadb(char *line, int len, int count, struct mediadb* last, int sort, int flag)
    428428{
     
    10791079        if(path == NULL)
    10801080        {
    1081                 findfiles("/media", type, 0, 0);
     1081                findfiles("/media", type);
    10821082                /*
    10831083                addhddall();
     
    10891089                        {
    10901090                                tmpstr = ostrcat("/autofs/", hddnode->device, 0, 0);
    1091                                 findfiles(tmpstr, type, 1, 0);
     1091                                findfiles(tmpstr, type);
    10921092                                free(tmpstr); tmpstr = NULL;
    10931093                        }
     
    10971097        }
    10981098        else
    1099                 findfiles(path, type, 0, 0);
     1099                findfiles(path, type);
    11001100
    11011101        writemediadb(getconfig("mediadbfile", NULL));
     
    16411641}
    16421642
    1643 // flag = 0 (rekursive aktive)
    1644 // flag = 1 (rekursive deactive)
    1645 // flag1 = 0 (scan files and start)
    1646 // flag1 = 1 (count files)
    1647 int findfiles(char* dirname, int type, int flag, int flag1)
    1648 {
    1649         debug(777, "dir=%s type=%d flag=%d flag1=%d\n", dirname, type, flag, flag1);
     1643//flag: bit 31 = 0 (rekursive), 1 (no recursive)
     1644//flag: bit 30 = 0 (scan files and start), 1 (count files)
     1645int findfiles(char* dirname, int flag)
     1646{
     1647        int type = flag;
     1648        int onlydir = checkbit(flag, 31);
     1649        int onlycount = checkbit(flag, 30);
     1650
     1651        type = clearbit(type, 31);
     1652        type = clearbit(type, 30);
     1653
     1654        debug(777, "dir=%s type=%d onlydir=%d, onlycount=%d\n", dirname, type, onlydir, onlycount);
    16501655        DIR *d;
    16511656        //Open the directory specified by dirname
     
    16851690                                {
    16861691                                        err("path length has got too long");
    1687                                         return 1;
     1692                                        return -1;
    16881693                                }
    16891694                                //Recursively call findfiles with the new path
    1690                                 if(flag == 0)
    1691                                         findfiles(path, type, 1, 0);
     1695                                if(onlydir == 0)
     1696                                        findfiles(path, type);
    16921697                        }
    16931698                }
     
    17001705                                if(type == 0 || type == 100 || type == 90 || type == 91)
    17011706                                {
    1702                                         if(flag1 == 0)
     1707                                        if(onlycount == 0)
    17031708                                                mediadbfindfilecb(path, entry->d_name, 0);
    17041709                                        else
     
    17111716                                if(type == 1 || type == 100 || type == 90 || type == 92)
    17121717                                {
    1713                                         if(flag1 == 0)
     1718                                        if(onlycount == 0)
    17141719                                                mediadbfindfilecb(path, entry->d_name, 1);
    17151720                                        else
     
    17221727                                if(type == 2 || type == 100 || type == 91 || type == 92)
    17231728                                {
    1724                                         if(flag1 == 0)
     1729                                        if(onlycount == 0)
    17251730                                                mediadbfindfilecb(path, entry->d_name, 2);
    17261731                                        else
     
    17351740        {
    17361741                perr("Could not close %s", dirname);
    1737                 return 1;
    1738         }
    1739 
    1740         if(flag1 == 1)
     1742                return -1;
     1743        }
     1744
     1745        if(onlycount == 1)
    17411746                return count;
    17421747        return 0;
Note: See TracChangeset for help on using the changeset viewer.