]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - filelist.c
Add support to decompress xz files
[thirdparty/sarg.git] / filelist.c
index e851a00cfafc4d22c001490120f935a7d881a1dc..d4395645d4bdbf6db7564b6b3d6d6b1204a5befc 100644 (file)
@@ -439,20 +439,11 @@ const char *FileListIter_Next(struct _FileListIterator *FIter)
                globfree(&FIter->Glob);
                FIter->NextGlob=0;
        }
-       /*
-        * Try every pattern until the list is exhausted or a real error
-        * occurs or a file is matched.
-        */
-       while ((Path=FileListIter_NextWithMask(FIter))!=NULL)
+       Path=FileListIter_NextWithMask(FIter);
+       if (Path!=NULL && (Path[0]!='-' || Path[1]!='\0'))
        {
                int ErrCode=glob(Path,GLOB_ERR | GLOB_NOSORT,NULL,&FIter->Glob);
-               if (ErrCode==0)//success
-               {
-                       Path=FIter->Glob.gl_pathv[0];
-                       FIter->NextGlob=1;
-                       break;
-               }
-               if (ErrCode!=GLOB_NOMATCH)
+               if (ErrCode!=0)
                {
                        switch (ErrCode)
                        {
@@ -462,9 +453,17 @@ const char *FileListIter_Next(struct _FileListIterator *FIter)
                        case GLOB_ABORTED:
                                debuga(__FILE__,__LINE__,_("Read error while listing the files matching \"%s\"\n"),Path);
                                break;
+                       case GLOB_NOMATCH:
+                               debuga(__FILE__,__LINE__,_("No files matching \"%s\"\n"),Path);
+                               break;
+                       default:
+                               debuga(__FILE__,__LINE__,_("Failed to glob file pattern \"%s\" with unspecified error code %d"),Path,ErrCode);
+                               break;
                        }
                        exit(EXIT_FAILURE);
                }
+               Path=FIter->Glob.gl_pathv[0];
+               FIter->NextGlob=1;
        }
 #else
        /*