-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbfsize.c
More file actions
44 lines (36 loc) · 675 Bytes
/
bfsize.c
File metadata and controls
44 lines (36 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Copyright (C) 2011 <fwhacking|gmail:com>
*
* This is free software, licensed under the GNU General Public License v2.
* See /LICENSE for more information.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
static void print_usage(const char *name)
{
printf("Usage: %s file\n", name);
}
int main(int argc, char **argv)
{
FILE *fd;
long size;
if (argc != 2)
{
print_usage(argv[0]);
exit(1);
}
fd = fopen(argv[1], "rb");
if (fd == NULL)
{
printf("Could not read the file '%s'\n", argv[1]);
print_usage(argv[0]);
exit(1);
}
size = fseek(fd, 0L, SEEK_END);
size = ftell(fd);
fclose(fd);
printf("%ld\n", size);
exit(0);
}