]>
Commit | Line | Data |
---|---|---|
25697a35 | 1 | /* |
94ff9470 | 2 | * SARG Squid Analysis Report Generator http://sarg.sourceforge.net |
110ce984 | 3 | * 1998, 2015 |
25697a35 GS |
4 | * |
5 | * SARG donations: | |
6 | * please look at http://sarg.sourceforge.net/donations.php | |
1164c474 FM |
7 | * Support: |
8 | * http://sourceforge.net/projects/sarg/forums/forum/363374 | |
25697a35 GS |
9 | * --------------------------------------------------------------------- |
10 | * | |
11 | * This program is free software; you can redistribute it and/or modify | |
12 | * it under the terms of the GNU General Public License as published by | |
13 | * the Free Software Foundation; either version 2 of the License, or | |
14 | * (at your option) any later version. | |
15 | * | |
16 | * This program is distributed in the hope that it will be useful, | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | * GNU General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU General Public License | |
22 | * along with this program; if not, write to the Free Software | |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
24 | * | |
25 | */ | |
26 | ||
27 | #include "include/conf.h" | |
5f3cfd1d | 28 | #include "include/defs.h" |
25697a35 GS |
29 | |
30 | ||
32e71fa4 | 31 | void index_only(const char *dirname,int debug) |
25697a35 | 32 | { |
9bd92830 FM |
33 | DIR *dirp; |
34 | struct dirent *direntp; | |
35 | char remove[MAXLEN]; | |
e21b6c02 | 36 | |
9bd92830 | 37 | if ((dirp = opendir(dirname)) == NULL) { |
af961877 | 38 | debuga(__FILE__,__LINE__,_("Cannot open directory \"%s\": %s\n"),dirname,strerror(errno)); |
9bd92830 FM |
39 | exit(EXIT_FAILURE); |
40 | } | |
41 | while ( (direntp = readdir( dirp )) != NULL ){ | |
56b97279 | 42 | if(strcmp(direntp->d_name,".") == 0 || strcmp(direntp->d_name,"..") == 0 || strcmp(direntp->d_name, INDEX_HTML_FILE) == 0) |
9bd92830 | 43 | continue; |
e21b6c02 | 44 | |
9bd92830 | 45 | if (snprintf(remove,sizeof(remove),"%s/%s",dirname,direntp->d_name)>=sizeof(remove)) { |
af961877 | 46 | debuga(__FILE__,__LINE__,_("Name of the file to remove is too long. File name is \"%s/%s\"\n"),dirname,direntp->d_name); |
9bd92830 FM |
47 | continue; |
48 | } | |
49 | if (unlink(remove) == -1) { | |
af961877 | 50 | debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),remove,strerror(errno)); |
9bd92830 FM |
51 | } |
52 | } | |
25697a35 | 53 | |
9bd92830 | 54 | (void)closedir( dirp ); |
25697a35 | 55 | |
9bd92830 | 56 | return; |
25697a35 | 57 | } |