Reputation: 2595
I get the "Error: could not check file size". Any idea why?
// Generate Content-Length
int file_size;
int fd;
char clenbuf[BUFLEN];
struct stat fs;
fd = open(filename, "r");
if (fstat(fd, &fs) == -1) {
printf("Error: could not check file size\n");
return;
}
file_size = fs.st_size;
sprintf(clenbuf, "Content-Length: %d", file_size);
Upvotes: 0
Views: 150
Reputation: 64730
Try it this way:
fd = open(filename, "r");
if (NULL == fd) {
printf("Could not open the file\n");
exit(0);
}
if (fstat(fd, &fs) == -1) {
printf("Error: could not check file size\n");
return;
}
Upvotes: 1