diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-02-26 08:15:40 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-02-26 08:15:40 +0800 |
commit | f4a2cd7df6027651042667c5e330f2e922b0c9f9 (patch) | |
tree | c0537dc3b5ce481eefb7cd6aad88688d4a9d7461 | |
parent | c0341b44ef5512036249fc21987b1751e81419c5 (diff) | |
download | pttbbs-f4a2cd7df6027651042667c5e330f2e922b0c9f9.tar pttbbs-f4a2cd7df6027651042667c5e330f2e922b0c9f9.tar.gz pttbbs-f4a2cd7df6027651042667c5e330f2e922b0c9f9.tar.bz2 pttbbs-f4a2cd7df6027651042667c5e330f2e922b0c9f9.tar.lz pttbbs-f4a2cd7df6027651042667c5e330f2e922b0c9f9.tar.xz pttbbs-f4a2cd7df6027651042667c5e330f2e922b0c9f9.tar.zst pttbbs-f4a2cd7df6027651042667c5e330f2e922b0c9f9.zip |
reduce number of system call
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2554 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/record.c | 8 |
1 files changed, 4 insertions, 4 deletions
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; } |