Change the working directory.

@param  string  $path
@param  \Closure  $callback
@return \Basset\Collection|\Basset\Directory
764601
public function directory($path, Closure $callback = null)
    {
        try
        {
            $path = $this->finder->setWorkingDirectory($path);

            $this->directories[$path] = new Directory($this->factory, $this->finder, $path);

            // Once we've set the working directory we'll fire the callback so that any added assets
            // are relative to the working directory. After the callback we can revert the working
            // directory.
            is_callable($callback) and call_user_func($callback, $this->directories[$path]);

            $this->finder->resetWorkingDirectory();

            return $this->directories[$path];
        }
        catch (DirectoryNotFoundException $e)
        {
            $this->getLogger()->error(sprintf('Directory "%s" could not be found in "%s"', $path, $this->path));

            return new Directory($this->factory, $this->finder, null);
        }
    }
348514
public function post( $path, callable $callback ) {
        $route = new Route( 'POST', $path, $callback );
        $this->_routes[] = $route;
        return $route;
    }
1252564
public function patch(String $path, Callable $callback) : Route {

		return $this->collectRoute('PATCH', $path, $callback);

	}
483926
static function chdir($dir, $callback = null, $argv = array())
    {
        if (!is_dir($dir)) {
            throw new \InvalidArgumentException("$dir does not exist.");
        }

        $cwd = getcwd();
        chdir($dir);

        if (null === $callback) {
            return;
        }

        $returnValue = call_user_func_array($callback, $argv);

        chdir($cwd);
        return $returnValue;
    }
985166
public function changePath($path)
    {
        $pathname = $this->createPathname($path, $this->getBasename(), $this->getExtension());

        return new static($pathname);
    }
1067789
def set_working_directory(self, path):
        
        """
        _complain_ifclosed(self.closed)
        return self.fs.set_working_directory(path)
673179
protected function appendIterator(\Closure $callback = null)
    {
        $iterator = new \AppendIterator();

        $paths = (array) parent::getArrayCopy();

        $clousre = function ($path) use ($callback, $iterator) {
            $iterator->append($callback($path));
        };

        foreach ($this as $path) {
            if ($this->isSubdir($path)) {
                continue;
            }

            $clousre($path);
        }

        return $iterator;
    }
485588
public function map(Closure $callback)
    {
        return new self(array_map($callback, $this->items, array_keys($this->items)));
    }
896372
public function extend($driver, Closure $callback)
    {
        $this->factory->extend($driver, $callback);

        return $this;
    }
1006383
function (path, callback) {
    var mkdir = child_process.spawn('mkdir', ['-p', path]);
    mkdir.on('error', function (err) {
        callback(err);
        callback = function(){};
    });
    mkdir.on('exit', function (code) {
        if (code === 0) callback();
        else callback(new Error('mkdir exited with code: ' + code));
    });
}
1100071
public function sortMultiDimension(Closure $callback)
    {
        foreach ($this->items as &$sortable) {
            uasort($sortable, $callback);
        }
        unset($sortable);

        return $this;
    }
153036
public function directory($path, callable $callable = null)
    {
        $directory_path = $this->makePath($path);

        $this->outbox->createDir($directory_path);

        $context = clone($this->context);
        $context->directory = $directory_path;

        $sub = new static($this->outbox, $this->stubbox, $context);

        if ($callable) {
            call_user_func($callable, $sub);
        }

        return $sub;
    }
629598
public function each( \Closure $callback )
	{
		foreach( $this->items as $name => $properties )
		{
			if( $callback($properties, $name) === false )
			{
				break;
			}
		}

		return $this;
	}
1125404
protected function createBrowsersFor(Closure $callback)
    {
        if (count(static::$browsers) === 0) {
            static::$browsers = collect([$this->newBrowser($this->createWebDriver())]);
        }

        $additional = $this->browsersNeededFor($callback) - 1;

        for ($i = 0; $i < $additional; $i++) {
            static::$browsers->push($this->newBrowser($this->createWebDriver()));
        }

        return static::$browsers;
    }
305241
public static function purgePresets($path = null, $callback = null) {
        $moufManager = MoufManager::getMoufManager();
        $instances = $moufManager->findInstances('Mouf\\Utils\\Graphics\\MoufImagine\\Controller\\ImagePresetController');
        foreach ($instances as $instanceName) {
            $instance = $moufManager->getInstance($instanceName);
            if ($path && strpos($path, $instance->originalPath) !== false) {
                $imagePath = substr($path, strlen($instance->originalPath) + 1);
                $instance->deletePreset($imagePath);
                
                if(is_callable($callback)) {
                    $finalPath = ROOT_PATH . $instance->url . DIRECTORY_SEPARATOR . $imagePath;
                    $callback($finalPath);
                }
            }
        }
    }
166885
private function _changeDirectory($path)
    {
        if ($this->isSFTP()) {
            $changed = @$this->ftp->chdir($path);
        } else {
            $changed = @ftp_chdir($this->ftp, $path);
        }
        if (!$changed) {
            $this->fail("couldn't change directory {$path}");
        }
    }
776267
public function cancelWatch($path, $callback = null)
	{
		if (isset($this->callback[$path])) {
			if (empty($callback)) {
				unset($this->callback[$path]);
				$this->zookeeper->get($path); //reset the callback
				return true;
			} else {
				$key = array_search($callback, $this->callback[$path]);
				if ($key !== false) {
					unset($this->callback[$path][$key]);
					return true;
				} else {
					return null;
				}
			}
		} else {
			return null;
		}
	}