static function fs($path, $is_utf8 = true) { static $fs; isset($fs) or $fs = new \COM('Scripting.FileSystemObject', null, CP_UTF8); $path = explode('://', $path, 2); $path = $path[(int) isset($path[1])]; $path = strtr($path, '/', '\\'); $pre = ''; if (!isset($path[0]) || '/' !== $path[0] && '\\' !== $path[0] && false === strpos($path, ':')) { $pre = getcwd() . '\\'; } $pre = new \VARIANT($pre); if ($is_utf8) { $path = new \VARIANT($path, VT_BSTR, CP_UTF8); } else { $path = new \VARIANT($path); } return array($fs, $fs->getAbsolutePathName(variant_cat($pre, $path))); }
public static function fs($path, $is_utf8 = true) { static $fs; if (!class_exists('COM', false)) { throw new \RuntimeException('The `wfio` or `com_dotnet` extension is required to handle UTF-8 filesystem access on Windows'); } isset($fs) or $fs = new \COM('Scripting.FileSystemObject', null, CP_UTF8); $path = explode('://', $path, 2); $path = $path[(int) isset($path[1])]; $path = strtr($path, '/', '\\'); $pre = ''; if (!isset($path[0]) || '/' !== $path[0] && '\\' !== $path[0] && false === strpos($path, ':')) { $pre = getcwd() . '\\'; } $pre = new \VARIANT($pre); if ($is_utf8) { $path = new \VARIANT($path, VT_BSTR, CP_UTF8); } else { $path = new \VARIANT($path); } return array($fs, $fs->getAbsolutePathName(variant_cat($pre, $path))); }