function translate($path)
    {
        if(static::isWindowsOS())
        {
            if(preg_match('%^([A-Z]):(.*)%', $path, $matches))
            {
                // $path contains something like 'C:' at the start,
                // so it's an absolute path from the root.

                $drive = $matches[1];
                $file = $matches[2];
                $unixFile = str_replace('\\', '/', $file);

                if(static::isWindowsMsys())
                {
                    $path = '/' . strtolower($drive) . $unixFile;
                }
                else if(static::isWindowsCygwin())
                {
                    $path = '/cygdrive/' . strtolower($drive) . $unixFile;
                }
            }
            else
            {
                // $path does not look like 'C:' so we assume it to be relative
                if(static::isWindowsMsys() || static::isWindowsCygwin())
                    $path = str_replace('\\', '/', $path);;
            }
        }

        return $path;
    }
function translate($path)
    {
        if(static::isWindowsOS())
        {
            if(preg_match('%^([A-Z]):(.*)%', $path, $matches))
            {
                // $path contains something like 'C:' at the start,
                // so it's an absolute path from the root.

                $drive = $matches[1];
                $file = $matches[2];
                $unixFile = str_replace('\\', '/', $file);

                if(static::isWindowsMsys())
                {
                    $path = '/' . strtolower($drive) . $unixFile;
                }
                else if(static::isWindowsCygwin())
                {
                    $path = '/cygdrive/' . strtolower($drive) . $unixFile;
                }
            }
            else
            {
                // $path does not look like 'C:' so we assume it to be relative
                if(static::isWindowsMsys() || static::isWindowsCygwin())
                    $path = str_replace('\\', '/', $path);;
            }
        }

        return $path;
    }
function translate ( $ path ) { if ( static :: isWindowsOS ( ) ) { if ( preg_match ( '%^([A-Z]):(.*)%' , $ path , $ matches ) ) { // $path contains something like 'C:' at the start, // so it's an absolute path from the root. $ drive = $ matches [ 1 ] ; $ file = $ matches [ 2 ] ; $ unixFile = str_replace ( '\\' , '/' , $ file ) ; if ( static :: isWindowsMsys ( ) ) { $ path = '/' . strtolower ( $ drive ) . $ unixFile ; } else if ( static :: isWindowsCygwin ( ) ) { $ path = '/cygdrive/' . strtolower ( $ drive ) . $ unixFile ; } } else { // $path does not look like 'C:' so we assume it to be relative if ( static :: isWindowsMsys ( ) || static :: isWindowsCygwin ( ) ) $ path = str_replace ( '\\' , '/' , $ path ) ; ; } } return $ path ; }
Translate a Windows path into a POSIX path, if necessary.

On POSIX systems this does nothing.

On Windows+MSYS:   "C:\Windows" => "/c/Windows"
On Windows+Cygwin: "C:\Windows" => "/cygdrive/c/Windows"

@param string $path The input path which may be absolute or relative
@return string POSIX path
Translate a Windows path into a POSIX path if necessary .