f



DJGPP problem with getting file size via fstat or not implemented yet?

Hi, I compiled the Wavpack lossless codec tool and found a problem in funct=
ion DoGetFileSize() that on unix systems use this code:

struct stat statbuf;

    if (!hFile || fstat (fileno (hFile), &statbuf) || !(statbuf.st_mode & S=
_IFREG))
        return 0;

    return (int64_t) statbuf.st_size;

The problem is that it returns zero. So I used lfilelength(fileno(hFile) fu=
nction that works. Does it mean that there's a bug in fstat or it is not im=
plemented at all (just a dummy)? Does lfilelength() supports >2GB files on =
enabled filesystems (like NTFS under NTVDM)?
0
RayeR
12/20/2016 11:04:44 AM
comp.os.msdos.djgpp 3308 articles. 0 followers. tigrepotrazosalvaje (34) is leader. Post Follow

6 Replies
161 Views

Similar Articles

[PageSpeed] 5

On 12/20/16, RayeR (glaux@centrum.cz) [via djgpp@delorie.com]
<djgpp@delorie.com> wrote:
> Hi, I compiled the Wavpack lossless codec tool and found a problem in
> function DoGetFileSize() that on unix systems use this code:
>
> struct stat statbuf;
>
>     if (!hFile || fstat (fileno (hFile), &statbuf) || !(statbuf.st_mode &
> S_IFREG))
>         return 0;
>
>     return (int64_t) statbuf.st_size;
>
> The problem is that it returns zero.

The problem is not with fstat(): break that if construct into smaller
pieces and check every step, and you shall see that it is the S_IFREG
check on st_mode which is failing. Djgpp defines S_IFREG as 0x0000, so
it is no miracle that it fails.  Replace !(statbuf.st_mode & S_IFREG)
with !S_ISREG(statbuf.st_mode) and it shall work.

>  So I used lfilelength(fileno(hFile)
> function that works. Does it mean that there's a bug in fstat or it is not
> implemented at all (just a dummy)? Does lfilelength() supports >2GB files on
> enabled filesystems (like NTFS under NTVDM)?
0
Ozkan
12/20/2016 2:26:09 PM
Thanks for reply. Yes it makes sense, according to reference
https://linux.die.net/man/2/fstat
I'll check and and I will try to suggest this modification to Wavpack authors.

And do you know if it and lfilelength supports large files (64b size)?
0
RayeR
12/20/2016 3:24:59 PM
On 12/20/16, RayeR (glaux@centrum.cz) [via djgpp@delorie.com]
<djgpp@delorie.com> wrote:
> Thanks for reply. Yes it makes sense, according to reference
> https://linux.die.net/man/2/fstat
> I'll check and and I will try to suggest this modification to Wavpack
> authors.
>
> And do you know if it and lfilelength supports large files (64b size)?
>

Quoting from its documentation:

"The return value is of type @code{long long} which allows file sizes of
2^63-1 bytes to be returned.  Note that FAT16 limits files to near
2^31 bytes and FAT32 limits files to 2^32-2 bytes."

I never used it though (never needed it.)
0
Ozkan
12/20/2016 4:01:05 PM
OK, I changed the condition to
    if (!hFile || fstat (fileno (hFile), &statbuf) || !S_ISREG(statbuf.st_m=
ode)) as you suggested and it works. I dont have large NTFS partition to tr=
y the limit. Maybe someone else with insight into djdev can tell us which o=
f this functions supports large files. I personally don't care too, I never=
 wavpacked large files and I still use FAT16 & 32...
0
RayeR
12/20/2016 11:27:52 PM
Hi,

On Tuesday, December 20, 2016 at 5:27:53 PM UTC-6, RayeR wrote:
>
> OK, I changed the condition to
>
>   if (!hFile || fstat (fileno (hFile), &statbuf) ||
>   !S_ISREG(statbuf.st_mode))
>
> as you suggested and it works. I dont have large NTFS partition
> to try the limit. Maybe someone else with insight into djdev
> can tell us which of this functions supports large files. I
> personally don't care too, I never wavpacked large files and I
> still use FAT16 & 32...

IIRC, there was an attempt (by CWS?), circa 2.04 beta, to partially
support 4 GB files in FAT32 under Win9x. But I don't know how well
it was tested, and it might not have been worth it (too kludgy?
needs oddball DOS function calls? e.g. int 21h, 716Ch ??). It may
not even work at all under 2k/XP, dunno.

Besides, FreeDOS' FAT32 is limited to 2 GB per file anyways, not
sure about other implementations.

Anyways, we still have old real-mode WavPack DOS binaries from 2002.
However, if you think your port is stable enough, I'll mirror it to
iBiblio for FreeDOS and us, if you want.

P.S. FreeDOS 1.2 final is scheduled to be released in a week.
0
rugxulo
12/21/2016 4:00:11 AM
BTW Wavpack probably comes with some newer incompatible format because I ca=
nnot play some files with old Winamp 2.x plugin (Win9x) cca from 2002-2003 =
but can be played with new plugin using KernelEx under Win98. So I guess th=
at old Wavpack codec from 2002 have same problem. I put my binaries and sou=
rces on Sourceforge (also FFMPEX and X264 was updated yesterday).
0
RayeR
12/21/2016 11:18:41 AM
Reply: