int add_attach(char *file1, char *file2, char *filename)
{
FILE *fp, *fp2;
struct stat st;
uint32_t size;
char o[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
char buf[1024 * 16];
int i;
if (stat(file2, &st) == -1)
return 0;
if (st.st_size >= 2 * 1024 * 1024 && !HAS_PERM(currentuser, PERM_SYSOP)) {
unlink(file2);
return 0;
}
size = htonl(st.st_size);
fp2 = fopen(file2, "rb");
if (!fp2)
return 0;
fp = fopen(file1, "ab");
fwrite(o, 1, 8, fp);
for (i = 0; i < strlen(filename); i++)
if (!isalnum(filename[i]) && filename[i] != '.' && filename[i] > 0)
filename[i] = 'A';
fwrite(filename, 1, strlen(filename) + 1, fp);
fwrite(&size, 1, 4, fp);
while ((i = fread(buf, 1, 1024 * 16, fp2))) {
fwrite(buf, 1, i, fp);
}
fclose(fp2);
fclose(fp);
unlink(file2);
return st.st_size;
}
【 在 atppp (Big Mouse) 的大作中提到: 】
: 没发现。贴相关的代码我好search吧...
: 可能我的和你的不是一个版本:p
--
FROM 202.120.189.*