From f4a2cd7df6027651042667c5e330f2e922b0c9f9 Mon Sep 17 00:00:00 2001 From: kcwu Date: Sat, 26 Feb 2005 00:15:40 +0000 Subject: reduce number of system call git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2554 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/record.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'mbbsd/record.c') diff --git a/mbbsd/record.c b/mbbsd/record.c index 47b62010..28e6dee9 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -36,12 +36,12 @@ get_sum_records(char *fpath, int size) { struct stat st; int ans = 0; - int fp; + FILE *fp; fileheader_t fhdr; char buf[200], *p; // Ptt : should avoid big loop - if ((fp = open(fpath, O_RDONLY))==-1) + if ((fp = fopen(fpath, "r"))==NULL) return -1; strlcpy(buf, fpath, sizeof(buf)); @@ -49,12 +49,12 @@ get_sum_records(char *fpath, int size) assert(p); p++; - while (read(fp, &fhdr, size) == size) { + while (fread(&fhdr, size, 1, fp)==1) { strcpy(p, fhdr.filename); if (stat(buf, &st) == 0 && S_ISREG(st.st_mode) && st.st_nlink == 1) ans += st.st_size; } - close(fp); + fclose(fp); return ans / 1024; } -- cgit v1.2.3