aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-php-shim/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe-php-shim/src')
-rw-r--r--crates/shirabe-php-shim/src/fs.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/crates/shirabe-php-shim/src/fs.rs b/crates/shirabe-php-shim/src/fs.rs
index e70d397..ee2bbee 100644
--- a/crates/shirabe-php-shim/src/fs.rs
+++ b/crates/shirabe-php-shim/src/fs.rs
@@ -798,6 +798,12 @@ pub fn file_put_contents3(_filename: &str, _data: &str, _flags: i64) -> Option<i
}
pub fn file_get_contents(path: impl AsRef<std::path::Path>) -> Option<String> {
+ let path = path.as_ref();
+ // PHP supports the file:// stream wrapper; strip it to read the local file.
+ let path = path
+ .to_str()
+ .and_then(|s| s.strip_prefix("file://"))
+ .map_or(path, std::path::Path::new);
std::fs::read(path)
.ok()
.map(|bytes| String::from_utf8_lossy(&bytes).into_owned())