@param string $container
@param string $path
@param bool   $force
@param bool   $content_only

@throws \Exception
970433
public function deleteFolder($container, $path, $force = false, $content_only = false)
    {
        $dir = static::addContainerToName($container, $path);
        FileUtilities::deleteTree($dir, $force, !$content_only);
    }
810925
private function createFile($path, $contents = '', $mode = 0666)
    {
        if (false === file_put_contents($path, $contents)) {
            throw new RuntimeException(
                sprintf(
                    'The file "%s" could not be written.',
                    $path
                )
            );
        }

        if (!chmod($path, $mode)) {
            throw new RuntimeException(
                sprintf(
                    'The file "%s" could not be chmodded to %o.',
                    $path,
                    $mode
                )
            );
        }
    }
108724
static function remove($path, $onlyFiles=false) {
		if (!file_exists($path)) {
			return true;
		}
		if (is_dir($path)) {
			if ($onlyFiles) throw new FileException("$path is a directory!");
			return self::removeDir($path);
		}
		else {
			$ok=unlink($path);
			if (!$ok) throw new FileAccessException("Could not delete file $path");
		}
		return true;
	}
511827
public function loadContainer($containerPath)
    {
        $containerPath = realpath($containerPath);

        if (false === $containerPath) {
            return false;
        }

        $this->container = new ContainerBuilder();

        try {
            $loader = new XmlFileLoader($this->container, new FileLocator(dirname($containerPath)));
            $loader->load(basename($containerPath));

            return true;
        } catch (\Exception $e) {
            return false;
        }
    }
33054
public function parseBlock(Text $content, Container $target)
    {
        $content->handle(
            '/^\s*$/m',
            function (Text $line) use ($target) {
                $target->addChild(new BlankLine($line));
            },
            function (Text $part) use ($target) {
                $paragraph = new Paragraph($part);
                $target->addChild($paragraph);

                $this->inlineParser->queue($paragraph->getText(), $paragraph);
            }
        );
    }
690162
private function doPermChange(string $path, vfsStreamAbstractContent $content, callable $change): bool
    {
        if (!$content->isOwnedByUser(vfsStream::getCurrentUser())) {
            return false;
        }

        if (self::$root->getName() !== $path) {
            $names   = $this->splitPath($path);
            $parent = $this->getContent($names['dirname']);
            if (!$parent->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup())) {
                return false;
            }
        }

        $change();
        return true;
    }
285090
protected function _invokeTasks($path, $content) {
		$tasks = $this->getTasks($path, $content);

		foreach ($tasks as $task) {
			if (!$task->shouldRun($path)) {
				continue;
			}

			$task->annotate($path);
		}
	}
409521
public function filePutsContent($path, $content)
    {
        if (@file_put_contents($path, $content) === false) {
            throw new \RuntimeException(sprintf("Could't puts content %s", $path));
        }

        chmod($path, 0777);
    }
882385
public function deleteContainers($containers, $force = false)
    {
        if (!empty($containers)) {
            if (!isset($containers[0])) {
                // single folder, make into array
                $containers = [$containers];
            }
            foreach ($containers as $key => $folder) {
                try {
                    // path is full path, name is relative to root, take either
                    $name = array_get($folder, 'name', trim(array_get($folder, 'path'), '/'));
                    if (!empty($name)) {
                        $this->deleteContainer($name, $force);
                    } else {
                        throw new DfException('No name found for container in delete request.');
                    }
                } catch (\Exception $ex) {
                    // error whole batch here?
                    $containers[$key]['error'] = ['message' => $ex->getMessage(), 'code' => $ex->getCode()];
                }
            }
        }

        return $containers;
    }
646823
public function copyFile($container, $dest_path, $src_container, $src_path, $check_exist = false)
    {
        // does this file already exist?
        if (!$this->fileExists($src_container, $src_path)) {
            throw new NotFoundException("File '$src_path' does not exist.");
        }
        if ($this->fileExists($container, $dest_path)) {
            if (($check_exist)) {
                throw new BadRequestException("File '$dest_path' already exists.");
            }
        }
        // does this file's parent folder exist?
        $parent = FileUtilities::getParentFolder($dest_path);
        if (!empty($parent) && (!$this->folderExists($container, $parent))) {
            throw new NotFoundException("Folder '$parent' does not exist.");
        }

        // create the file
        $this->checkContainerForWrite($container); // need to be able to write to storage
        $file = static::addContainerToName($src_container, $dest_path);
        $srcFile = static::addContainerToName($container, $src_path);
        $result = copy($srcFile, $file);
        if (!$result) {
            throw new InternalServerErrorException('Failed to copy file.');
        }
    }
1255894
public function streamFile($container, $path, $download = false)
    {
        $params = ($download) ? ['disposition' => 'attachment'] : [];
        $this->streamBlob($container, $path, $params);
    }
207327
public static function create(string $path, string $content = '', bool $overwrite = true): self
    {
        $path = normalize_path($path);

        if (is_file($path) && $overwrite) {
            self::unlink($path);
        }
        if (!is_file($path)) {
            if (is_writeable(dirname($path))) {
                if ($handle = fopen($path, 'w')) {
                    fwrite($handle, $content);
                    fclose($handle);

                    return new static($path);
                }
                throw new FileException('Creating file ('.$path.') failed');
            }
            throw new FileException('Cannot create file, because the directory ('.dirname($path).') is not accessible',
                FileException::NOT_WRITEABLE);
        }
        throw new FileException('Cannot create file, because the file path ('.$path.') already exist', FileException::ALREADY_EXIST);
    }
1071149
private function simpleItemUpload($path, $content, $conflictBehavior)
    {
        if (!in_array($conflictBehavior, ['fail', 'replace', 'rename'])) {
            throw new OneDriveClientException('Incorrect conflict behavior parameter value');
        }

        $url = self::BASE_URI.$this->getPathUnderRootDrive($path).':/content?@name.conflictBehavior='.$conflictBehavior;

        return $this->getResponse('PUT', $url, $content);
    }
345966
protected function handleFileContent(
        $dest_path,
        $dest_name,
        $content,
        $contentType = '',
        $extract = false,
        $clean = false,
        $check_exist = false
    ){
        $ext = FileUtilities::getFileExtension($dest_name);
        if (empty($contentType)) {
            $contentType = FileUtilities::determineContentType($ext, $content);
        }
        if ((FileUtilities::isZipContent($contentType) || ('zip' === $ext)) && $extract) {
            // need to extract zip file and move contents to storage
            $tempDir = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
            $tmpName = $tempDir . $dest_name;
            file_put_contents($tmpName, $content);
            $zip = new \ZipArchive();
            $code = $zip->open($tmpName);
            if (true !== $code) {
                unlink($tmpName);

                throw new InternalServerErrorException('Error opening temporary zip file. code = ' . $code);
            }

            $results = $this->extractZipFile($dest_path, $zip, $clean);
            unlink($tmpName);

            return $results;
        } else {
            $fullPathName = FileUtilities::fixFolderPath($dest_path) . $dest_name;
            $this->driver->writeFile($this->container, $fullPathName, $content, false, $check_exist);

            return ['name' => $dest_name, 'path' => $fullPathName, 'type' => 'file'];
        }
    }
1272421
public function blobExists($container = '', $name = '')
    {
        $this->checkConnection();
        try {
            /** @var Container $container */
            $container = $this->blobConn->getContainer($container);
            if (empty($container)) {
                throw new \Exception("No container named '$container'");
            }

            $obj = $container->DataObject($name);

            return !empty($obj);
        } catch (\Exception $ex) {
        }

        return false;
    }
684455
public static function put(string $path, string $contents, bool $lock = false): int
    {
        return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
    }
189011
public function setFileRaw( string$key, string$contentType, string$content, string$fileName=null ):self
	{
		$this->files[$key]= [
			'fileName'=> $fileName??md5($content),
			'contentType'=> $contentType,
			'content'=> $content,
		];

		return $this;
	}