pdf-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pdf-devel] FS module, file readable/writeable


From: Zac Brown
Subject: Re: [pdf-devel] FS module, file readable/writeable
Date: Mon, 28 Jul 2008 06:48:04 -0700
User-agent: Thunderbird 2.0.0.16 (X11/20080724)

Aleksander Morgado wrote:
   And BTW, we should probably have an additional function for multiple
   checks, like a wrapper for the access() function.

   Then the pdf_fsys_item_p, pdf_fsys_item_is_readable_p and
   pdf_fsys_item_is_writable_p functions could even be macros calling
   pdf_fsys_item_access.

That modification would involve to change the filesystem
implementation interface. Not all filesystems will have an access-like
functionality in a native way.

As a matter of convenience we could provide a pdf_fsys_item_access
function
that would internally use the pdf_fsys_item_* functions.

We basically have this already with pdf_fsys_get_item_props. My
intention is to just have pdf_fsys_item_{writable/readable}_p call that
function in the disk implementation.

That's not the good way to do it.

Checking if the file is readable or writable does not mean it has the
read access bit or the write access bit. The filesystem could be mounted
read-only, so those bits are not useful.

The proper way would be to call access() function to check if the file
is readable or writable. That function takes into account both the
partition access permissions and the file access permissions.

For pdf_fsys_get_item_p I went the route of just trying to open the
file. Though I could just make it call pdf_fsys_get_item_props as well.


Again, you can't only try to read the file to know if the file exists.
What if you don't have read access but you have write access? You can
call again access() function with the F_OK flag for that.

-Aleksander

Ya, Jose pointed that out to me.

-Zac




reply via email to

[Prev in Thread] Current Thread [Next in Thread]