Skip to content

Commit

Permalink
Enable configuration fix for solving Windows 2 WSL2 issue with is_rea…
Browse files Browse the repository at this point in the history
…dable/is_writable #189
  • Loading branch information
mosbth committed Nov 17, 2022
1 parent d5ca10c commit 4589b3b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
9 changes: 9 additions & 0 deletions CCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ public function getPathToSubdir($subdir, $create = true)
return $path;
}

if ($create && defined('WINDOWS2WSL')) {
// Special case to solve Windows 2 WSL integration
$path = $this->path . "/" . $subdir;

if (mkdir($path)) {
return realpath($path);
}
}

if ($create && is_writable($this->path)) {
$path = $this->path . "/" . $subdir;

Expand Down
7 changes: 5 additions & 2 deletions CImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -964,8 +964,11 @@ public function loadImageDetails($file = null)
{
$file = $file ? $file : $this->pathToImage;

is_readable($file)
or $this->raiseError('Image file does not exist.');
// Special case to solve Windows 2 WSL integration
if (!defined('WINDOWS2WSL')) {
is_readable($file)
or $this->raiseError('Image file does not exist.');
}

$info = list($this->width, $this->height, $this->fileType) = getimagesize($file);
if (empty($info)) {
Expand Down
8 changes: 8 additions & 0 deletions REVISION.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ Revision history
[![Build Status](https://scrutinizer-ci.com/g/mosbth/cimage/badges/build.png?b=master)](https://scrutinizer-ci.com/g/mosbth/cimage/build-status/master)


v0.8.5 (2022-11-17)
-------------------------------------

* Enable configuration fix for solving Windows 2 WSL2 issue with is_readable/is_writable #189.
* Update CHttpGet.php for php 8.1 deprecated notice #188.



v0.8.4 (2022-05-30)
-------------------------------------

Expand Down
9 changes: 9 additions & 0 deletions webroot/img_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
define("CIMAGE_DEBUG_FILE", "/tmp/cimage");
}

/**
* Set this if you work with a webserver in Windows and try to access files
* within WSL2.
* The issue seems to be with functions like `is_writable()` and
* `is_readable()`.
* When WINDOWS2WSL is defined (to any value) it ignores these functions.
*/
#define('WINDOWS2WSL', 1);



return array(
Expand Down

0 comments on commit 4589b3b

Please sign in to comment.