/*
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net
- * 1998, 2010
+ * 1998, 2015
*
* SARG donations:
* please look at http://sarg.sourceforge.net/donations.php
void index_only(const char *dirname,int debug)
{
- DIR *dirp;
- struct dirent *direntp;
- char remove[MAXLEN];
+ DIR *dirp;
+ struct dirent *direntp;
+ char remove[MAXLEN];
- if ((dirp = opendir(dirname)) == NULL) {
- debuga(_("Failed to 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)
- continue;
+ if ((dirp = opendir(dirname)) == NULL) {
+ 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_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);
- continue;
- }
- if (unlink(remove) == -1) {
- debuga(_("Failed to remove the file %s\n"),remove);
- }
- }
+ if (snprintf(remove,sizeof(remove),"%s/%s",dirname,direntp->d_name)>=sizeof(remove)) {
+ 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(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),remove,strerror(errno));
+ }
+ }
- (void)closedir( dirp );
+ (void)closedir( dirp );
- return;
+ return;
}