[physfs] PHYSFS_seek is too simple

Tim Čas darkuranium at gmail.com
Mon Dec 3 13:42:38 EST 2012


Well, as stated, you can just compute that by yourself without the
parameter. Look at the code on SO.com again -- it *does* use the parameter
-- it uses it to compute the final position.

I'm not the maintainer of the library, but I think it would be a *very* bad
idea to add a redundant feature for something which can be gotten around so
easily.

And since fseek() cannot work with negative indices, why should this? I
don't see why it couldn't be so simple (or even simpler -- ignore this case
as it won't happen anyways).
In either case, what should be read anyways if you try to seek at, say,
file position -10? 0x00? 0xFF? EOF? ... there's a reason why fseek() cannot
work with that.

On top of the API change problems, you'd also add dangerous portability
problems if SEEK_* constants are defined differently for the lib and the
program using it.

On 3 December 2012 19:37, fy <fy0748 at gmail.com> wrote:

> **
> 在 Tue, 04 Dec 2012 00:27:45 +0800,Tim Čas <darkuranium at gmail.com> 写道:
>
>
> One more thing, which I forgot to mention...
>
> ... I don't know whether seeking w/ fseek before the start of file is
> implementation-defined or straight out undefined. In either case, the
> Vorbis API should not be doing the former because of portability concerns,
> and should not be doing the latter because, well, it's undefined.
>
> If it's the former (impl-defined) and you're feeling paranoid, you can
> always just do the thing I've specified in the previous email -- what's
> important is that it's consistent.
> If it's the latter (undefined), you don't need to worry about handling it
> at all, since for all the standard cares, it could summon (in the case of
> fseek) nasal demons.
>
> That's in theory anyways -- in practice, as stated, I highly doubt the API
> would do such a nasty thing due to the aforementioned reasons.
>
>
> OK. Now I tired, but failed.
>
> Then I load whole file into memory.I got a record of func calls by codes
> of stackoverflow :
>
> SEEK_END
> SEEK_END
> SEEK_SET
> SEEK_SET
>
> The "fromwhere" parameter is REALLY needed.
>
>
> As to this code snippet,
>
> > if(type == SEEK_CUR)
> > {
> > if(pos < -diff) // in other words, if `pos + diff` would be negative
> > pos = 0;
> > else
> > pos += diff;
> > }
>
> It can't be so easy.
>
>
> Anyway the problem is solved, not in the best way.
>
> So I think it should be patched.
>
>
> --
> 使用Opera的电子邮件客户端:http://www.opera.com/mail/
>
> _______________________________________________
> physfs mailing list
> physfs at icculus.org
> http://icculus.org/mailman/listinfo/physfs
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://icculus.org/pipermail/physfs/attachments/20121203/f44007b2/attachment.htm>


More information about the physfs mailing list