# is_readable and include path

- Thread: https://externals.io/message/25979
- Original archive: https://news-web.php.net/php.internals/25979
- Started by Ralph Schindler on 2006-10-06T21:57:59+00:00
- Messages: 6
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #25979 — Ralph Schindler — 2006-10-06T21:57:59+00:00

URL: https://externals.io/message/25979#25979

In the spirit of fopen's optional [, bool use_include_path].. is this 
something that can be added to is_readable?

ie:

bool is_readable ( string filename [, bool use_include_path] )



-ralph

---

## #25985 — Lukas Kahwe Smith — 2006-10-07T06:45:56+00:00

URL: https://externals.io/message/25979#25985 · In reply to: #25979

Ralph Schindler wrote:
> In the spirit of fopen's optional [, bool use_include_path].. is this 
> something that can be added to is_readable?
> 
> ie:
> 
> bool is_readable ( string filename [, bool use_include_path] )

we can always dream ..
so far the answer has been that this parameter should never have been 
added to `fopen()`, and that `file_exists()`, is_readable and friends should 
never get this feature. IIRC the reason was that they should not be 
reading the include path, however even proposing to be atleast able to 
pass in an order list of search pathes has been shot down. nevermind the 
common use case for such a feature.

*sigh*

regards,
Lukas

---

## #25997 — Sara Golemon — 2006-10-08T17:33:42+00:00

URL: https://externals.io/message/25979#25997 · In reply to: #25985

> > […]
> 
> we can always dream ..
> so far the answer has been that this parameter should never have been 
> added to `fopen()`, and that `file_exists()`, is_readable and friends should 
> never get this feature. IIRC the reason was that they should not be 
> reading the include path, however even proposing to be atleast able to 
> pass in an order list of search pathes has been shot down. nevermind the 
> common use case for such a feature.
> 
How about something which will save having to resolve that path twice?

$realpath = stream_resolve_include_path($relativepath);

if ($realpath && is_readable($realpath)) {
   $fp = fopen($realpath, 'rb', false);
} else {
   /* File isn't readable */
}

The code for doing this is all in there, it'd just need some quick 
exposing to userspace...

-Sara

---

## #25998 — Ralph Schindler — 2006-10-09T03:56:02+00:00

URL: https://externals.io/message/25979#25998 · In reply to: #25997

Sara Golemon wrote:
> > […]

I prefer the word "mature" instead of dream ;)

> > […]
> How about something which will save having to resolve that path twice?
> 
> $realpath = stream_resolve_include_path($relativepath);
> 
> if ($realpath && is_readable($realpath)) {
>   $fp = fopen($realpath, 'rb', false);
> } else {
>   /* File isn't readable */
> }
> 
> The code for doing this is all in there, it'd just need some quick 
> exposing to userspace...
> 
> -Sara

that is an interesting suggestion,.. in researching other options, how 
about this:

string realpath ( string path [, bool use_include_path])

This makes more sense to me, plus it can be done once and wont have to 
worry about including this in the family of file functions.  This seems 
like a logical place to resolve paths., including file that reside in 
the relative include-path.

Think this can fly?

-ralph

---

## #26089 — Ralph Schindler — 2006-10-18T19:56:18+00:00

URL: https://externals.io/message/25979#26089 · In reply to: #25997

Is it worth even attempting to create a patch and submitting it to do 
the following:

string realpath ( string path [, bool use_include_path])

or will it be shot down?

There must be a way to find the full path to a file that resides in one 
of the include paths no?  I can understand not wanting it in fopen, and 
 `file_exists()`, but this seems like the appropriate place.

-ralph

---

## #26090 — Ilia Alshanetsky — 2006-10-18T20:55:41+00:00

URL: https://externals.io/message/25979#26090 · In reply to: #26089

-1 for the idea. I think using include_path for `realpath()` goes  
against the code logic that should be applied by realpath.

Ilia Alshanetsky
