summaryrefslogtreecommitdiffstats
path: root/mbbsd/record.c
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-06-26 10:03:37 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-06-26 10:03:37 +0800
commit450ad26421aa1c38700dddc8899a3522e1cc5442 (patch)
tree92cd9e2cacca48bb627263c985b69f84037081d5 /mbbsd/record.c
parent42d9500f4b43e6f6c5680d1a2fd5065164698d1f (diff)
downloadpttbbs-450ad26421aa1c38700dddc8899a3522e1cc5442.tar
pttbbs-450ad26421aa1c38700dddc8899a3522e1cc5442.tar.gz
pttbbs-450ad26421aa1c38700dddc8899a3522e1cc5442.tar.bz2
pttbbs-450ad26421aa1c38700dddc8899a3522e1cc5442.tar.lz
pttbbs-450ad26421aa1c38700dddc8899a3522e1cc5442.tar.xz
pttbbs-450ad26421aa1c38700dddc8899a3522e1cc5442.tar.zst
pttbbs-450ad26421aa1c38700dddc8899a3522e1cc5442.zip
Merge bbs merge moduleptt.fpg@2092
usage: make -D BBSMERGE to enable this module git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2091 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/record.c')
-rw-r--r--mbbsd/record.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/mbbsd/record.c b/mbbsd/record.c
index a11b3a56..3551ebad 100644
--- a/mbbsd/record.c
+++ b/mbbsd/record.c
@@ -36,24 +36,25 @@ get_sum_records(char *fpath, int size)
{
struct stat st;
long ans = 0;
- FILE *fp;
+ int fp;
fileheader_t fhdr;
char buf[200], *p;
-
- if (!(fp = fopen(fpath, "r")))
+
+ // Ptt : should avoid big loop
+ if ((fp = open(fpath, O_RDONLY))==-1)
return -1;
-
+
strlcpy(buf, fpath, sizeof(buf));
p = strrchr(buf, '/');
assert(p);
p++;
- while (fread(&fhdr, size, 1, fp) == 1) {
+ while (read(fp, &fhdr, size) == size) {
strcpy(p, fhdr.filename);
if (stat(buf, &st) == 0 && S_ISREG(st.st_mode) && st.st_nlink == 1)
ans += st.st_size;
}
- fclose(fp);
+ close(fp);
return ans / 1024;
}
@@ -426,17 +427,16 @@ safe_article_delete_range(char *direct, int from, int to)
int apply_record(char *fpath, int (*fptr) (), int size){
char abuf[BUFSIZE];
- FILE *fp;
+ int fp;
- if (!(fp = fopen(fpath, "r")))
- return -1;
+ if((fp=open(fpath, O_RDONLY, 0))) return -1;
- while (fread(abuf, 1, size, fp) == (size_t)size)
+ while (read(fp, abuf, size) == (size_t)size)
if ((*fptr) (abuf) == QUIT) {
- fclose(fp);
+ close(fp);
return QUIT;
}
- fclose(fp);
+ close(fp);
return 0;
}