]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - indexonly.c
Generate redirector log even if -d is not given
[thirdparty/sarg.git] / indexonly.c
index 8cdf1188705aa9aeaacf9c47118a1f495001ef70..b6d44bb00915f0f977b5b202f90110ff247be5b7 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * SARG Squid Analysis Report Generator      http://sarg.sourceforge.net
- *                                                            1998, 2010
+ *                                                            1998, 2015
  *
  * SARG donations:
  *      please look at http://sarg.sourceforge.net/donations.php
@@ -35,19 +35,19 @@ void index_only(const char *dirname,int debug)
        char remove[MAXLEN];
 
        if ((dirp = opendir(dirname)) == NULL) {
-               debuga(_("Failed to open directory %s - %s\n"),dirname,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot open directory \"%s\": %s\n"),dirname,strerror(errno));
                exit(EXIT_FAILURE);
        }
        while ( (direntp = readdir( dirp )) != NULL ){
-               if(strcmp(direntp->d_name,".") == 0 || strcmp(direntp->d_name,"..") == 0 || strcmp(direntp->d_name, "index.html") == 0)
+               if(strcmp(direntp->d_name,".") == 0 || strcmp(direntp->d_name,"..") == 0 || strcmp(direntp->d_name, INDEX_HTML_FILE) == 0)
                        continue;
 
                if (snprintf(remove,sizeof(remove),"%s/%s",dirname,direntp->d_name)>=sizeof(remove)) {
-                       debuga(_("Name of the file to remove is too long: %s/%s\n"),dirname,direntp->d_name);
+                       debuga(__FILE__,__LINE__,_("Name of the file to remove is too long. File name is \"%s/%s\"\n"),dirname,direntp->d_name);
                        continue;
                }
                if (unlink(remove) == -1) {
-                       debuga(_("Failed to remove the file %s\n"),remove);
+                       debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),remove,strerror(errno));
                }
        }