protected function format($path)
    {
        //replace back slash with forward
        $path = str_replace('\\', '/', $path);

        //replace double forward slash with 1 forward slash
        $path = str_replace('//', '/', $path);

        //if there is a last forward slash
        if (substr($path, -1, 1) == '/') {
            //remove it
            $path = substr($path, 0, -1);
        }

        //if the path does not start with a foward slash
        //and the path does not have a colon
        //(this is a test for windows)
        if (substr($path, 0, 1) != '/' && !preg_match("/^[A-Za-z]+\:/", $path)) {
            //it's safe to add a slash
            $path = '/'.$path;
        }

        return $path;
    }