rfc:linking_in_stream_wrappers
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rfc:linking_in_stream_wrappers [2014/10/25 11:18] – created thekid | rfc:linking_in_stream_wrappers [2021/03/27 14:47] (current) – Move to inactive ilutov | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2014-10-25 | * Date: 2014-10-25 | ||
* Author: Timm Friebe, thekid@php.net | * Author: Timm Friebe, thekid@php.net | ||
- | * Status: | + | |
+ | | ||
* First Published at: https:// | * First Published at: https:// | ||
Line 12: | Line 13: | ||
Userland stream wrappers must be able to hook into: | Userland stream wrappers must be able to hook into: | ||
- | 1. Creating links | + | 1. Creating links |
- | 2. Testing for links' existance | + | |
- | 3. Returning file type | + | |
- | 4. Resolving links | + | |
- | Currently, #2 and #3 are already supported by [[http:// | + | Currently, #2 and #3 are already supported by [[http:// |
- | + | ||
- | With this accomplished, | + | |
+ | Use case #1 - **new functionality**: | ||
< | < | ||
class wrapper { | class wrapper { | ||
/** | /** | ||
- | | + | * Creates a hard link to the existing target with the specified name link. |
* | * | ||
* @param | * @param | ||
Line 36: | Line 36: | ||
/** | /** | ||
- | | + | * Creates a symbolic link to the existing target with the specified name link. |
* | * | ||
* @param | * @param | ||
Line 45: | Line 45: | ||
// ... | // ... | ||
} | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Use cases #2 and #3 - //already possible today//: | ||
+ | <PHP> | ||
+ | class wrapper { | ||
+ | |||
+ | /** | ||
+ | * See http:// | ||
+ | * | ||
+ | * @param | ||
+ | * @param | ||
+ | * @return array or FALSE on error | ||
+ | */ | ||
+ | function url_stat($url, | ||
+ | if ($flags & STREAM_URL_STAT_LINK) { | ||
+ | // Stat the link, not the file it points to | ||
+ | } | ||
+ | |||
+ | // ... | ||
+ | |||
+ | return [ | ||
+ | // ... | ||
+ | ' | ||
+ | ]; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Use case #4 - **new functionality**: | ||
+ | <PHP> | ||
+ | class wrapper { | ||
/** | /** | ||
- | | + | * Reads a link and returns the target |
* | * | ||
* @param | * @param | ||
- | * @return string The link target or NULL | + | * @return string The link target or FALSE if the does not exist |
*/ | */ | ||
function url_readlink($link) { | function url_readlink($link) { | ||
Line 56: | Line 88: | ||
} | } | ||
} | } | ||
+ | </ | ||
+ | |||
+ | * When url_readlink() returns a string, it will be used as readlink()' | ||
+ | * When url_readlink() returns FALSE, readlink() quietly returns FALSE | ||
+ | * For all other return values of url_readlink(), | ||
+ | * When url_readlink() is not implemented, | ||
+ | |||
+ | ==== Limitations ==== | ||
+ | |||
+ | It will not be possible to create links between two different stream wrappers like this: | ||
+ | |||
+ | <PHP> | ||
+ | symlink(' | ||
</ | </ | ||
Line 91: | Line 136: | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
TODO: Implement and submit GitHub pull request. | TODO: Implement and submit GitHub pull request. | ||
+ | https:// | ||
===== References ===== | ===== References ===== | ||
- | See http:// | + | * http:// |
- | See https:// | + | * [[https:// |
+ | * [[https:// |
rfc/linking_in_stream_wrappers.txt · Last modified: 2021/03/27 14:47 by ilutov