Create path if needed.

@param string $path

@return bool TRUE on success or if path already exists, FALSE if path cannot be created.
339691
private function createPathIfNeeded($path)
	{
		return  !(!\is_dir($path) && !@\mkdir($path, 0777 & (~$this->umask), true) && !\is_dir($path));
	}
732190
public function checkPath($path)
    {
        $path = realpath($path);

        return ($path !== false && is_dir($path)) ? $path : false;
    }
120034
public static function createFolder($path)
    {
        $path = self::resolve($path);

        return $path && (is_dir($path) || mkdir($path, 0700, true));
    }
793260
public function isValidPath($path)
    {
        $isValidPath = false;

        $pathValue = $this->getValueByPath($path);
        if (!is_null($pathValue)) {
            $isValidPath = true;
        }

        return $isValidPath;
    }
1182138
public static function addPath($path)
    {
        $path = str_replace('//', '/', rtrim($path, '/'));
        if (is_dir($path) && !in_array($path, self::$_paths)) {
            array_unshift(self::$_paths, $path);
        }
    }
512739
private function realPath($path)
    {
        $result = realpath($path);
        if ($result === false) {
            throw new \InvalidArgumentException(sprintf('Failed to run realpath(\'%s\')', $path));
        }

        return $result;
    }
200025
public function createFile(string $path): File {
    $localFile = $this->instantiateFile($path);
    $localFile->create();
    return $localFile;
  }
1017277
protected static function isValidPath($path)
    {
        if (strpos($path, '?') !== false) {
            return false;
        }
        if (strpos($path, '*') !== false) {
            return false;
        }
        if (strpos($path, ':') !== false) {
            return false;
        }
        if (strpos($path, '|') !== false) {
            return false;
        }
        if (strpos($path, '\\') !== false) {
            return false;
        }
        if (strpos($path, '<') !== false) {
            return false;
        }
        if (strpos($path, '>') !== false) {
            return false;
        }
        if (strpos($path, '"') !== false) {
            return false;
        }

        return true;
    }
378486
protected function makeDirectory($path)
    {
        $dir = dirname($path);

        if (!file_exists($dir)) {
            mkdir($dir, 0777, true);
        }
    }
1012779
protected function _makeDir($path): bool
    {
        return $path && (is_dir($path) || @mkdir($path, 0664, true)) && is_writable($path);
    }
1372266
protected function createFileDir($path)
    {
        if (!file_exists($path)) {
            $this->createFileDir(dirname($path));
            mkdir($path, 0777);
        }
    }
1241260
public static function create($path = false, $mode = 0777) {

        if($path && !self::isFolder(dirname($path)) && self::isWritable(dirname($path))) {

            mkdir($path, $mode);

            if(Folder::isFolder($path)) {

                return true;
            }
        } 

        return false;
    }
745130
public function createFolder($path) : bool
	{
		$path = $this->normalizePath($path);
		
		// Check if the path contains folders we dont want to create
		if (str_contains($path, $this->folderPathExcludeList)) {
			return true;
		}
		
		$this->folderPath = '/sites/'.$this->siteName.'/Shared%20Documents';
		
		$requestUrl = $this->siteUrl.'/sites/'.$this->siteName.'/_api/Web/folders';
		
		$this->requestHeaders['Content-Type'] = 'application/json;odata=verbose';
		
		$folderAttributes = [
			'__metadata' => [
				'type' => 'SP.Folder',
			],
			'ServerRelativeUrl' => $this->folderPath.$path,
		];
		
		$options = [
			'headers' => $this->requestHeaders,
			'body' => json_encode($folderAttributes)
		];
		
		$response = $this->send('POST', $requestUrl, $options);
		
		return $response->getStatusCode() === 200 ? true : false;
	}
1164778
public function exists($path)
	{
		// Explode the registry path into an array
		$nodes = explode('.', $path);

		if ($nodes)
		{
			// Initialize the current node to be the registry root.
			$node = $this->data;

			// Traverse the registry to find the correct node for the result.
			for ($i = 0, $n = count($nodes); $i < $n; $i++)
			{
				if (isset($node->$nodes[$i]))
				{
					$node = $node->$nodes[$i];
				}
				else
				{
					break;
				}

				if ($i + 1 == $n)
				{
					return true;
				}
			}
		}

		return false;
	}
204998
public function createFile($path)
    {
        $created = fopen($path, "w");
        if (false === $created)
            return false;

        fclose($created);
        return true;
    }
774303
public function exists(string $path){
    if ( !empty($path) ){
      $dir = dirname($path);
      $ext = \bbn\str::file_ext($path);
      $file = basename($path);
      if ( \is_array($files = $this->listFiles($dir)) ){
        foreach ( $files as $f ){
          if ( $f['basename'] === $file ){
            return true;
          }
        }
      }
    }
    return false;
  }
713841
public function createDirectory(string $path): Directory {
    $localDirectory = $this->instantiateDir($path);
    $localDirectory->create();
    return $localDirectory;
  }