From 1f2456d052f54631285a96959e774c3f008846f1 Mon Sep 17 00:00:00 2001 From: piaip Date: Thu, 15 Sep 2005 10:51:26 +0000 Subject: make textlen an option git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3177 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/bbs.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index a14c197c..1bda4b80 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -828,11 +828,13 @@ do_general(int isbid) struct stat st; postfile.multi.money = aborted; +#ifdef USE_TEXTLEN if (stat(fpath, &st) != -1) { /* put original file (text) length. */ postfile.textlen = st.st_size; } +#endif } strlcpy(postfile.owner, owner, sizeof(postfile.owner)); @@ -1161,13 +1163,17 @@ edit_post(int ent, fileheader_t * fhdr, const char *direct) setdirpath(genbuf, direct, fhdr->filename); local_article = fhdr->filemode & FILE_LOCAL; - if(fhdr->textlen <= 0) - Copy(genbuf, fpath); - else +#ifdef USE_TEXTLEN + if(fhdr->textlen > 0) { /* TODO SYSOP may need some function to edit entire file. */ CopyN(genbuf, fpath, fhdr->textlen); } + else +#endif + { + Copy(genbuf, fpath); + } strlcpy(save_title, fhdr->title, sizeof(save_title)); @@ -1182,7 +1188,11 @@ edit_post(int ent, fileheader_t * fhdr, const char *direct) /* check textlen */ if(fhdr->textlen > 0) { - int gotnewstat = 0; + int gotnewstat = -1; + +#ifdef USE_TEXTLEN + /* TODO should we reload textlen info? + * multiple editing will make textlen invalid. */ if(fhdr->textlen != newstat.st_size) { #ifdef DEBUG @@ -1195,12 +1205,16 @@ edit_post(int ent, fileheader_t * fhdr, const char *direct) } else { gotnewstat = stat(fpath, &newstat); } +#endif + /* now update the record. */ if(gotnewstat != -1) fhdr->textlen = newstat.st_size; else fhdr->textlen = 0; + recordTouched = 1; + } else /* old flavor, no textlen info */ if (oldstat.st_mtime != newstat.st_mtime) { -- cgit v1.2.3