From c02feb19aa34449376f52805663414aefafdc06a Mon Sep 17 00:00:00 2001 From: Gonzalo Date: Tue, 7 Nov 2023 15:41:46 -0300 Subject: [PATCH] fix: fix file exists (#228) * fix: fix file exists * chore: rename variables --- src/_internal/Fs.sol | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/_internal/Fs.sol b/src/_internal/Fs.sol index 8be43e58..2a48af80 100644 --- a/src/_internal/Fs.sol +++ b/src/_internal/Fs.sol @@ -202,12 +202,16 @@ library fs { } catch Error(string memory) { return Ok(false); } catch (bytes memory reason) { - bytes4 selector = 0x0bc44503; - string memory errorMessage = + bytes32 errorHash = keccak256(bytes(abi.decode(removeSelector(reason), (string)))); + string memory linuxErrorMessage = string.concat("The path \"", path, "\" is not allowed to be accessed for read operations."); - bytes32 errorHash = keccak256(abi.encodeWithSelector(selector, errorMessage)); - if (keccak256(reason) == errorHash) { - return FsErrors.Forbidden(errorMessage).toBoolResult(); + bytes32 linuxErrorHash = keccak256(bytes(linuxErrorMessage)); + + string memory macErrorMessage = + string.concat("the path ", path, " is not allowed to be accessed for read operations"); + bytes32 macErrorHash = keccak256(bytes(macErrorMessage)); + if (errorHash == linuxErrorHash || errorHash == macErrorHash) { + return FsErrors.Forbidden(linuxErrorMessage).toBoolResult(); } return Ok(false); }