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

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


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)

look like with it?

-- 
Elias Pschernig





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