在HP Nonstop上,如何获取大于2GB的大文件的文件大小?

huangapple go评论63阅读模式
英文:

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

问题

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.
英文:

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

得分: 2

不确定为什么选项142即使使用无符号32位变量也不返回2 GB文件的大小。

您可以使用选项191,它将以64位变量返回大小。

以下是选项142的文档,建议对于更大的文件大小使用选项191。

聚合EOF。对于磁盘对象,文件的文件结束值。
对于已经打开整个文件的分区文件,返回整个文件的文件结束值。返回值
为%hFFFFFFFF表示文件结束值无法适应
这个无符号四字节属性。在这种情况下,要获取
文件结束值,请使用八字节属性,即项目代码
191。已被项目191替代。

英文:

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

huangapple
  • 本文由 发表于 2023年2月8日 15:29:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/75382547.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定