diff options
author | rodri <rgl@antares-labs.eu> | 2021-10-05 20:21:38 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2021-10-05 20:21:38 +0000 |
commit | c650339b2a8313ddb1730b588a6fc08c444dcb7d (patch) | |
tree | 4decf7b4eba4c4f8267944af0a8823dd528399cd | |
parent | 791e1a47049924611dbf58c5191837a89e8980a3 (diff) | |
download | filmoteca-master.tar.gz filmoteca-master.tar.bz2 filmoteca-master.zip |
-rw-r--r-- | filmoteca.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/filmoteca.c b/filmoteca.c index 751ac4e..0d871af 100644 --- a/filmoteca.c +++ b/filmoteca.c @@ -489,13 +489,8 @@ addresource(Index *idx, Resource *r) uint h; h = hash(r->title); - if(idx->rtab[h] == nil){ - idx->rtab[h] = r; - return; - } - for(rp = idx->rtab[h]; rp->next != nil; rp = rp->next) - ; - rp->next = r; + r->next = idx->rtab[h]; + idx->rtab[h] = r; } void @@ -527,6 +522,7 @@ initindex(Index *idx) Movie *m; Multipart *mp; Series *s; + void *media; DIR *dp; dirent *dpe; char **dirs, *d, path[512]; @@ -539,8 +535,10 @@ initindex(Index *idx) while(ndirs > 0){ rtype = Runknown; d = dirs[--ndirs]; + snprint(path, sizeof path, "%s/%s", wdir, d); dp = opendir(path); + while((dpe = readdir(dp)) != nil) if(strcmp(dpe->d_name, "video") == 0){ rtype = Rmovie; @@ -552,6 +550,7 @@ initindex(Index *idx) rtype = Rserie; break; } + if(rtype != Runknown) rewinddir(dp); else{ @@ -559,17 +558,25 @@ initindex(Index *idx) free(d); continue; } + switch(rtype){ case Rmovie: m = allocmovie(); + media = m; break; case Rmulti: mp = allocmultipart(); + media = mp; break; case Rserie: s = allocserie(); + media = s; break; } + + r = allocresource(d, rtype, media); + addresource(idx, r); + free(d); } } |