C on HP Nonstop: How to obtain filesize of large file > 2GB?

241 views Asked by At

I'm working on a C application which is running on HP-Nonstop and it needs to get the size of files on disk. The already implemented way of doing that is the following:

char *filename;
short itemlist;
long fileLength = 0;
short retCode;

itemlist = 142; /* file size */
retCode = FILE_GETINFOLISTBYNAME_( filename,
                                 (short)strlen(filename),
                                 &itemlist,
                                 1,
                                 (short*)&fileLength,
                                 sizeof(fileLength) );

As I read in the documentation this only works for files of size not greater than about 2GB:

If the file being referenced is an [...] OSS files larger than approximately 2 gigabytes, item codes will return -1 with no error indication.

Thus my questions:

  • How can I obtain the size of files bigger than 2GB?
  • Is there a way to have a look into how FILE_GETINFOLISTBYNAME_ is implemented? Maybe one could write their own implementation for large files.
1

There are 1 answers

1
Pras On BEST ANSWER

Not sure why option 142 does not return the size for 2 GB file even though it uses unsigned 32 bit variable to return the size.

You can use option 191 which would return the size in 64 bit variable.

Here is documentation for option 142 which is recommending to use option 191 for larger file size.

Aggregate EOF. For disk objects, the end-of-file value of the file. For a partitioned file where the entire file has been opened, the end-of-file value of the entire file is returned. A returned value of %hFFFFFFFF indicates that the end-of-file value cannot fit into this unsigned four-byteattribute. In this case, to obtain the end-of-file value, use the eight-byte attribute, which isitem code 191. Superseded by item 191