| 780 | } |
| 781 | |
| 782 | void listzipfiles(const char *dir, const char *ext, vector<char *> &files) // (does not list memfiles) |
| 783 | { |
| 784 | int extsize = ext ? (int)strlen(ext)+1 : 0, dirsize = (int)strlen(dir); |
| 785 | enumerate(zipfiles, zipfile *, zf, |
| 786 | { |
| 787 | if(strncmp(zf->fullname, dir, dirsize)) continue; |
| 788 | const char *name = zf->fullname + dirsize; |
| 789 | if(name[0] == PATHDIV) name++; |
| 790 | if(strchr(name, PATHDIV)) continue; |
| 791 | if(!ext) files.add(newstring(name)); |
| 792 | else |
| 793 | { |
| 794 | int namelength = (int)strlen(name) - extsize; |
| 795 | if(namelength > 0 && name[namelength] == '.' && strncmp(name+namelength+1, ext, extsize-1)==0) |
| 796 | files.add(newstring(name, namelength)); |
| 797 | } |
| 798 | }); |
| 799 | } |
| 800 | |
| 801 | void listzipdirs(const char *dir, vector<char *> &subdirs) // (does not list memfiles) |