diff options
author | scw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-04-12 10:37:05 +0800 |
---|---|---|
committer | scw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-04-12 10:37:05 +0800 |
commit | b1608f31a0d106c73f7538c6e4e0c8f9038a0cbf (patch) | |
tree | 4459a77ef7b9da0d8a558b70b6ca8cd49118c330 /mbbsd | |
parent | c9a206fc168c981c14098b55ae19ba90ab5194a9 (diff) | |
download | pttbbs-b1608f31a0d106c73f7538c6e4e0c8f9038a0cbf.tar pttbbs-b1608f31a0d106c73f7538c6e4e0c8f9038a0cbf.tar.gz pttbbs-b1608f31a0d106c73f7538c6e4e0c8f9038a0cbf.tar.bz2 pttbbs-b1608f31a0d106c73f7538c6e4e0c8f9038a0cbf.tar.lz pttbbs-b1608f31a0d106c73f7538c6e4e0c8f9038a0cbf.tar.xz pttbbs-b1608f31a0d106c73f7538c6e4e0c8f9038a0cbf.tar.zst pttbbs-b1608f31a0d106c73f7538c6e4e0c8f9038a0cbf.zip |
Avoid getting the same file name from stampfile() in utils.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1740 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/record.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/mbbsd/record.c b/mbbsd/record.c index 276e0b13..21f1b99d 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -476,19 +476,26 @@ stampfile(char *fpath, fileheader_t * fh) register char *ip = fpath; time_t dtime = COMMON_TIME; struct tm *ptime; -// int fp = 0; //Ptt: don't need to check +#ifdef _BBS_UTIL_C_ + int fp = 0; //Ptt: don't need to check + // for utils, the time may be the same between several runs, by scw +#endif if (access(fpath, X_OK | R_OK | W_OK)) mkdir(fpath, 0755); while (*(++ip)); *ip++ = '/'; -// do { +#ifdef _BBS_UTIL_C_ + do { +#endif sprintf(ip, "M.%d.A.%3.3X", (int)++dtime, rand() & 0xFFF); -// if (fp == -1 && errno != EEXIST) -// return -1; -// } while ((fp = open(fpath, O_CREAT | O_EXCL | O_WRONLY, 0644)) == -1); -// close(fp); +#ifdef _BBS_UTIL_C_ + if (fp == -1 && errno != EEXIST) + return -1; + } while ((fp = open(fpath, O_CREAT | O_EXCL | O_WRONLY, 0644)) == -1); + close(fp); +#endif memset(fh, 0, sizeof(fileheader_t)); strlcpy(fh->filename, ip, sizeof(fh->filename)); ptime = localtime(&dtime); |