[sword-devel] Confusing semantics for FileMgr::existsFile() and FileMgr::existsDir()

Jaak Ristioja jaak at ristioja.ee
Sat Oct 22 01:21:03 MST 2016


I instead suggest having a single function called isReadable(path) or
similar. Because when reading code like

    if (exists(path))

one will easily (if not always) miss that comment. If you keep calling
these existsFile() and existsDir() one will most likely assume
isFile()/isDir() semantics, while in reality these both instead have
isReadable() semantics.

J

On 22.10.2016 06:50, Troy A. Griffitts wrote:
> Thanks for pointing this out Jaak.  I've updated the comments to reflect
> that not only are file and dir checked for existence, but are also
> checked for readability.
> 
> On 10/21/2016 12:56 PM, Jaak Ristioja wrote:
>> Hi!
>>
>> In reality, the FileMgr::existsFile() and FileMgr::existsDir() static
>> methods not only check whether a file exists (or is visible to the
>> calling process), but also whether the given file is readable, because
>> internally, it uses the ::access system call with mode set to 04 which
>> is R_OK. Whereas it would suffice to use F_OK to check for existance.
>>
>> What should the correct semantics and function names be?
>>
>> Blessings,
>> J
>>
>> PS: Semantically, these two functions seem to duplicate one another,
>> except for memory requirements.
>>
>> _______________________________________________
>> sword-devel mailing list: sword-devel at crosswire.org
>> http://www.crosswire.org/mailman/listinfo/sword-devel
>> Instructions to unsubscribe/change your settings at above page
> 
> 
> _______________________________________________
> sword-devel mailing list: sword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page




More information about the sword-devel mailing list