![]() |
| | #1 | |||
| Registered User Join Date: Jun 2005 Location: Italy
Posts: 11
| [Large file][Value too large for defined data type] Code: /* Support Large File */
#define _FILE_OFFSET_BITS 64
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
int main()
{
FILE *fsource;
long img_size;
/* Open Image File */
if ((fsource = fopen("gnomebaker.iso", "rb")) == NULL)
{
fprintf(stderr, "%s\n", strerror(errno));
exit(EXIT_FAILURE);
}
fseek(fsource, 0L, SEEK_END);
img_size = (ftell(fsource));
printf("%s : size file %ld \n", strerror(errno), img_size);
return 1;
}
I've put in the first line "_FILE_OFFSET_BITS 64" for enable support file over 2GBs, but result all times is Value too large for defined data type. this is result with strace. Quote:
Quote:
Code: salsan@debian:~$ isoinfo -d -i gnomebaker.iso
CD-ROM is in ISO 9660 format
System id: LINUX
Volume id: Debian 4.0 r2 i386 Bin-1
Volume set id:
Publisher id:
Data preparer id:
Application id: MKISOFS ISO 9660/HFS FILESYSTEM BUILDER & CDRECORD CD-R/DVD CREATOR (C) 1993 E.YOUNGDALE (C) 1997 J.PEARSON/J.SCHILLING
Copyright File id:
Abstract File id:
Bibliographic File id:
Volume set size is: 1
Volume set sequence number is: 1
Logical block size is: 2048
Volume size is: 2293868
El Torito VD version 1 found, boot catalog is in sector 7007
Joliet with UCS level 3 found
Rock Ridge signatures version 1 found
Eltorito validation header:
Hid 1
Arch 0 (x86)
ID ''
Key 55 AA
Eltorito defaultboot header:
Bootid 88 (bootable)
Boot media 0 (No Emulation Boot)
Load segment 0
Sys type 0
Nsect 4
Bootoff 1B60 7008
Quote:
| |||
| salsan is offline | |
| | #2 |
| Registered User Join Date: Mar 2003
Posts: 3,900
| I don't think _FILE_OFFSET_BITS=64 will affect ftell() or fseek(). You'll have to use ftello() and fseeko() with the off_t type (from unistd.h). Or you could use fgetpos() and fsetpos() with the fpos_t type. http://www.gnu.org/software/libc/man...le-Positioning http://www.gnu.org/software/libc/man...le-Positioning gg |
| Codeplug is offline | |
| | #3 | |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Yes indeed, if your file is bigger than a "long", then you get: Quote:
-- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. | |
| matsp is offline | |
| | #4 | ||||
| Registered User Join Date: Jun 2005 Location: Italy
Posts: 11
| Quote:
Quote:
Code: /* Support Large File */
#define _FILE_OFFSET_BITS 64
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
int main()
{
FILE *fsource;
off_t img_size;
/* Open Image File */
if ((fsource = fopen("gnomebaker.iso", "rb")) == NULL)
{
fprintf(stderr, "%s\n", strerror(errno));
exit(EXIT_FAILURE);
}
fseeko(fsource, 0L, SEEK_END);
img_size = (ftello(fsource));
printf("%s : size file %ld \n", strerror(errno),(long int)(img_size));
return 1;
}
Quote:
Quote:
| ||||
| salsan is offline | |
| | #5 |
| Cat without Hat Join Date: Apr 2003
Posts: 8,492
| Reading the stdio.h header tells me that you need to #define __USE_LARGEFILE before including anything in order for these to be available.
__________________ All the buzzt! CornedBee"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code." - Flon's Law |
| CornedBee is offline | |
| | #7 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Yes, it looks like you should add Code: #define __USE_LARGEFILE64 -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. |
| matsp is offline | |
| | #8 | ||
| Registered User Join Date: Jun 2005 Location: Italy
Posts: 11
| Quote:
Code: /* Support Large File */
#define _FILE_OFFSET_BITS 64
#define __USE_LARGEFILE64
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
int main()
{
FILE *fsource;
off_t img_size;
/* Open Image File */
if ((fsource = fopen("gnomebaker.iso", "rb")) == NULL)
{
fprintf(stderr, "%s\n", strerror(errno));
exit(EXIT_FAILURE);
}
fseeko(fsource, 0L, SEEK_END);
img_size = (ftello(fsource));
printf("%s : size file %ld \n", strerror(errno),(long int)(img_size));
return 1;
}
Quote:
| ||
| salsan is offline | |
| | #9 |
| Cat without Hat Join Date: Apr 2003
Posts: 8,492
| Not 64. Just __USE_LARGEFILE. Or 64, and use fseeko64 and friends.
__________________ All the buzzt! CornedBee"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code." - Flon's Law |
| CornedBee is offline | |
| | #10 | ||
| Registered User Join Date: Jun 2005 Location: Italy
Posts: 11
| This is result if try with __USE_LARGEFILE Quote:
Quote:
| ||
| salsan is offline | |
| | #11 |
| Cat without Hat Join Date: Apr 2003
Posts: 8,492
| Works for me, without the warning.
__________________ All the buzzt! CornedBee"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code." - Flon's Law |
| CornedBee is offline | |
| | #12 | |||
| Registered User Join Date: Jun 2005 Location: Italy
Posts: 11
| Thanks more for your help, but is possible know version of your stdio.h Quote:
Quote:
Quote:
Now work this is my solution Code: /* Support Large File */
#define _FILE_OFFSET_BITS 64
#define _LARGEFILE_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
int main()
{
FILE *fsource;
off_t img_size;
/* Open Image File */
if ((fsource = fopen("gnomebaker.iso", "rb")) == NULL)
{
fprintf(stderr, "%s\n", strerror(errno));
exit(EXIT_FAILURE);
}
fseeko(fsource, 0L, SEEK_END);
img_size = (ftello(fsource));
printf("%s : size file %ld \n", strerror(errno),(long int)(img_size));
return 1;
}
Last edited by salsan; 02-05-2008 at 04:57 AM. Reason: fixed problem :-) | |||
| salsan is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Formatting/interpreting large amounts of data | robot-ic | Networking/Device Communication | 1 | 02-27-2009 12:26 PM |
| Problem collecting large string of data | gkoenig | C Programming | 3 | 03-01-2008 05:34 PM |
| large data handling | re- | C++ Programming | 2 | 05-26-2007 02:36 PM |
| gcc problem | bjdea1 | Linux Programming | 13 | 04-29-2002 06:51 PM |
| accepting large amounts of data | Sekti | C++ Programming | 1 | 04-05-2002 05:45 PM |