Skip to content

Commit

Permalink
Revert "use stat to get file size"
Browse files Browse the repository at this point in the history
This reverts commit 1ea37d8.
  • Loading branch information
andy5995 committed Nov 13, 2024
1 parent acc0339 commit 122466a
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions canfigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#include <ctype.h> // isspace()
#include <errno.h>
#include <sys/stat.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h> // free(), malloc()
Expand Down Expand Up @@ -280,15 +279,8 @@ read_entire_file(const char *filename)
return NULL;
}

//fseek(fp, 0, SEEK_END);
//long file_size = ftell(fp);
long file_size = -1;
struct stat st;
if (stat(filename, &st) == 0)
file_size = st.st_size;
else
perror("stat failed");

fseek(fp, 0, SEEK_END);
long file_size = ftell(fp);
if (file_size < 0)
{
fprintf(stderr, "Error getting the size of %s: %s\n", filename,
Expand Down

0 comments on commit 122466a

Please sign in to comment.