Changes the current directory.

        Change is made by running a "cd" command followed by a "clear" command.
        :param directory:
        :return:
512361
def change_directory(self, directory):
        
        self._process.write(('cd %s\n' % directory).encode())
        if sys.platform == 'win32':
            self._process.write((os.path.splitdrive(directory)[0] + '\r\n').encode())
            self.clear()
        else:
            self._process.write(b'\x0C')
1253393
def chdir(self, dir, change_os_dir=0):
        
        curr=self._cwd
        try:
            if dir is not None:
                self._cwd = dir
                if change_os_dir:
                    os.chdir(dir.get_abspath())
        except OSError:
            self._cwd = curr
            raise
618340
def change_dir(self, session, path):
        
        if path == "-":
            # Previous directory
            path = self._previous_path or "."

        try:
            previous = os.getcwd()
            os.chdir(path)
        except IOError as ex:
            # Can't change directory
            session.write_line("Error changing directory: {0}", ex)
        else:
            # Store previous path
            self._previous_path = previous
            session.write_line(os.getcwd())
673178
@Override
	public boolean cd(String directory) {
		boolean flag = true;
		try {
			flag = client.changeWorkingDirectory(directory);
		} catch (IOException e) {
			throw new FtpException(e);
		}
		return flag;
	}
1001732
def mkdir(dir, enter):
    

    if not os.path.exists(dir):
        os.makedirs(dir)
811822
public function setDirectory($directory)
    {
        $this->directory = $directory . DIRECTORY_SEPARATOR . $this->id;
        if (file_exists($this->directory) === false) {
            mkdir($this->directory, $this->fileMode, true);
        }
    }
755661
def _clear_dir(dirName):
    
    # If we got here, clear dir  
    for fname in os.listdir(dirName):
        try:
            os.remove( os.path.join(dirName, fname) )
        except Exception:
            pass
    try:
        os.rmdir(dirName)
    except Exception:
        pass
423963
def pushd(directory):
  
  cwd = os.getcwd()
  os.chdir(directory)
  try:
    yield directory
  finally:
    os.chdir(cwd)
1263376
def cd(*args):
    
    if args[0] == "-":
        try:
            newpwd, os.environ["OLDPWD"] = os.environ["OLDPWD"], os.getcwd()
        except KeyError as e:  # $OLDPWD initially not set
            raise e
        else:
            os.chdir(newpwd)
            print(newpwd)
    else:
        os.environ["OLDPWD"] = os.getcwd()
        os.chdir(*args)
1239344
public function setDirectory($directory) {

		if(false === is_string($directory)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($directory)), E_USER_ERROR);
		}

		$this -> directory = new Directory($directory);

		if(false === $this -> directory -> isWritable()) {
			return trigger_error(sprintf('Directory "%s" passed to %s() is not writable', $directory, __METHOD__), E_USER_ERROR);
		}

		return $this;
	}
1261626
protected function makeDir($directory)
	{
		if ( ! $this->files->isDirectory($this->getPath($directory)))
		{
			$this->files->makeDirectory($this->getPath($directory), 0777, true);
		}
	}
210200
private void cleanDirectory(File dir) {
		if (isVerbose() || getLog().isDebugEnabled()) {
			getLog().info("Deleting previously generated files in directory: " + dir.getPath());
		}
		if (dir.exists()) {
			try {
				FileUtils.cleanDirectory(dir);
			} catch (IOException e) {
				getLog().warn("Cleaning directory failed: " + e.getMessage());
			}
		}
	}
514855
public void changeDir(String dir)
        throws IOException, ServerException {
        if (dir == null) {
            throw new IllegalArgumentException("Required argument missing");
        }
        Command cmd = new Command("CWD", dir);
        try {
            controlChannel.execute(cmd);
        } catch (FTPReplyParseException rpe) {
            throw ServerException.embedFTPReplyParseException(rpe);
        } catch (UnexpectedReplyCodeException urce) {
            throw ServerException.embedUnexpectedReplyCodeException(
                                urce,
                                "Server refused changing directory");
        }
    }
722406
protected function cleanUpDir($directory)
    {
        $this->filesystem->removeDirectory($directory);
        $this->filesystem->ensureDirectoryExists($directory);
        return $this;
    }
79873
public static boolean createOrCleanDirectory(String directory) {
    // if the directory does not exist, create it.
    if (!FileUtils.isDirectoryExists(directory)) {
      LOG.fine("The directory does not exist; creating it.");
      if (!FileUtils.createDirectory(directory)) {
        LOG.severe("Failed to create directory: " + directory);
        return false;
      }
    }

    // Cleanup the directory
    if (!FileUtils.cleanDir(directory)) {
      LOG.severe("Failed to clean directory: " + directory);
      return false;
    }

    return true;
  }
1103411
def remove_directory(self, directory_name, *args, **kwargs):
		
		client = self.dav_client()
		remote_path = self.join_path(self.session_path(), directory_name)

		if client.is_dir(remote_path) is False:
			raise ValueError('Unable to remove non-directory entry')
		client.clean(remote_path)
871783
def pushd(directory: str) -> None:
    
    previous_dir = os.getcwd()
    os.chdir(directory)
    yield
    os.chdir(previous_dir)