Re: [AD] [4.3] fshooks and stat(2)

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Sunday 03 December 2006 5:33 am, Elias Pschernig wrote:
> On Sat, 2006-12-02 at 21:38 -0700, Thomas Fjellstrom wrote:
> > Currently my fshook code does whatever it can to hide the internals of
> > its structs from the user, giving them void pointers for handles, and
> > only letting the lib see the contents (and even then, its only the
> > vtable). This is all to reduce possiblity of ever breaking the abi or api
> > by modifiying the structs or vtable.
> >
> > stat(2) is a little tricky, so far my idea is to tie it to a AL_FILE
> > handle, so you can just call al_fs_file_ctime(handle), and you have your
> > ctime. What about directories you ask? Well thats what I want to know as
> > well. You _can_ allocate an AL_FILE handle without actually opening it,
> > and that will work on dir's so a al_fs_file_ctime on a AL_FILE that is
> > actually a directory WILL work, but it seems wrong.
> >
> > I was originally going to provide a AL_STAT handle to pass around, but
> > that also feels wrong, and makes the user have to free the handle (via
> > the api). Which also feels wrong.
> >
> > So, do I/we just mirror the stdio api, and use a plain struct, no handle,
> > no pointer? If its ever changed, it could easily break things. And I
> > would like to make it harder to break the abi, and api.
> >
> > I still want to keep the current AL_FILE embedded stat info, it just
> > "feels" right, especially after using Qt's QFile so much. (no it wont
> > "stat" each time stat info is requested, it stats once on handle
> > creation, and when ever the user calls al_fs_fstat on the handle)
> >
> > So yes, I'd like some input here.
>
> As a convenience, here's some of the most interesting files:
>
> http://alleg.svn.sourceforge.net/viewvc/alleg/allegro/branches/vfs-work-4.3
>/include/allegro/fshook.h?revision=7619&view=markup
> http://alleg.svn.sourceforge.net/viewvc/alleg/allegro/branches/vfs-work-4.3
>/include/allegro/internal/fshook.h?revision=7619&view=markup
> http://alleg.svn.sourceforge.net/viewvc/alleg/allegro/branches/vfs-work-4.3
>/src/fshook.c?revision=7619&view=markup
> http://alleg.svn.sourceforge.net/viewvc/alleg/allegro/branches/vfs-work-4.3
>/src/fshook_stdio.c?revision=7619&view=markup
>
> I didn't look very in-depth, but it seems to have everything we'd want.
>
> As for stat, how would e.g. the implementation of a function like:
>
> uint64_t filesize(char const *filename)

At the moment,
size_t al_fs_file_size(AL_FILE *);

You don't have to open the file, just create a new handle with
AL_FILE *al_fs_create_handle(char *path);

But this requires a handle, which is a bit inconvenient. Bob suggested maybe 
go with a static strict like libc, but reserve some space in case we want to 
expand the struct.

> look like with it?
>
> --
> Elias Pschernig
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

-- 
Thomas Fjellstrom
tfjellstrom@xxxxxxxxxx




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/