diff options
Diffstat (limited to 'mbbsd/record.c')
-rw-r--r-- | mbbsd/record.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/mbbsd/record.c b/mbbsd/record.c index 37d15870..17811fb8 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -626,3 +626,39 @@ append_record_forward(char *fpath, fileheader_t * record, int size, const char * return 0; } + +void +setaidfile(char *buf, const char *bn, aidu_t aidu) +{ + // try to load by AID + int bid = 0; + int n = 0, fd = 0; + char bfpath[PATHLEN] = ""; + boardheader_t *bh = NULL; + fileheader_t fh; + + buf[0] = 0; + bid = getbnum(bn); + + if (bid <= 0) return; + assert(0<=bid-1 && bid-1<MAX_BOARD); + bh = getbcache(bid); + if (!HasBoardPerm(bh)) return; + + setbfile(bfpath, bh->brdname, FN_DIR); + n = search_aidu(bfpath, aidu); + + if (n < 0) return; + fd = open(bfpath, O_RDONLY); + if (fd < 0) return; + + lseek(fd, n*sizeof(fileheader_t), SEEK_SET); + memset(&fh, 0, sizeof(fh)); + if (read(fd, &fh, sizeof(fh)) > 0) + { + setbfile(buf, bh->brdname, fh.filename); + if (!dashf(buf)) + buf[0] = 0; + } + close(fd); +} |