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: Aleksander Morgado
Subject: Re: [pdf-devel] FS module, file readable/writeable
Date: Sun, 27 Jul 2008 12:24:35 +0200
User-agent: Thunderbird 2.0.0.16 (X11/20080724)

Hi Hans,
> while working on the FS module unit test design I had some thoughts
> about pdf_fsys_item_readable_p() and pdf_fsys_item_writeable_p().
> Atm they return PDF_TRUE or PDF_FALSE depending on wether the given file
> is readable/writeable or not. But shouldn't both functions handle
> non-existing files, Or will they just return PDF_FALSE?
>   
I agree with you. Returning a pdf_status_t with an error code could be
better. Like PDF_OK if successful, PDF_ERROR if not, and PDF_EEXIST if
file doesn't exist.

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

Imagine the case where we want to check if a file exists, it's readable
and it's writable. It would be desirable to check all of those with a
single function call, and not:
if(pdf_fsys_item_p(filesystem, filepath) &&
   pdf_fsys_item_is_readable_p(filesystem,filepath) &&
   pdf_fsys_item_is_writable_p(filesystem,filepath))
{
   /* Do something */
}

So something like this could be useful:
pdf_status_t
pdf_fsys_item_access(pdf_fsys_t filesystem, pdf_text_t path_name, int
access_mode);

Where access_mode could be PDF_R_OK (check if readable), PDF_W_OK (check
if writable), PDF_X_OK (check if executable) and PDF_F_OK (check if exists).

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.


Of course, I am thinking in the Disk filesystem. Don't know how this can
be applied to other filesystem implementations, but probably there are
also methods to get multiple properties at the same time.


My 2 cents,

-Aleksander





reply via email to

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