Create a zip file from the current units.

@param string|null $path The pathname of the file o create. If not provided, file create a temporary file

@return string The zip file content
341040
public function createZipFile($path = null)
    {
        if ($path === null) {
            $path = tempnam(sys_get_temp_dir(), 'temp-zip-');
        }
        $zip = new \ZipArchive();
        $zip->open($path, \ZipArchive::CREATE);
        $this->addYmlFiles($zip);
        $zip->close();

        return $path;
    }
260653
public function makeDirectory($path)
    {
        if ('.' === $path || empty($path)) {
            $path = $this->localPath;
        } else {
            $path = "{$this->localPath}/{$path}";
        }

        return $this->filesystem->createDir($path);
    }
153152
static function createDirectories($path) {

		if (!$path) throw new \InvalidArgumentException("\$path can not be empty.");

		/*
		$parts=explode("/",$path);
		$pathPart="";
		foreach($parts as $i=>$p) {
			if ($i) $pathPart.="/";
			$pathPart.=$p;
			if ($pathPart) {
				if (@file_exists($pathPart) and !is_dir($pathPart)) {
					throw new FileException("\"$pathPart\" is a regular file!");
				}
				if (!(@file_exists($pathPart))) {
					self::mkdir($pathPart,false);
				}
			}
		}
		return $pathPart;
		 *
		 */

		if (file_exists($path)) {
			if (is_dir($path)) {
				return $path;
			}
			throw new FileException("\"$path\" is a regular file!");
		}

		$ret = @mkdir($path, 0777, true);
		if (!$ret) {
			throw new FileException("Directory \"$path\ could not be created.");
		}

		return $path;
	}
371547
static function zip($path, $zipPath) {
        $zip = new \ZipArchive();
        unlink($zipPath);
        if ($zip->open($zipPath, \ZipArchive::CREATE) === TRUE) {
            self::addFileToZip($path, $zip); //调用方法，对要打包的根目录进行操作，并将ZipArchive的对象传递给方法
            $zip->close(); //关闭处理的zip文件
        }
    }
14754
protected function fromFileType($path)
    {
        switch( Filesystem::getExtension($path) )
        {
            case 'png' : return imagecreatefrompng($path);
            case 'gif' : return imagecreatefromgif($path);
            case 'jpg' :
            case 'jpeg':
            default    : return imagecreatefromjpeg($path);
        }
    }
347688
public function set($path, $create = false)
    {
        $zip = $this->zip;
        $flag = $create ? $zip::CREATE : null;

        if ($this->zip->open($path, $flag) !== true) {
            throw new RuntimeException("Failed to open ZIP file $path");
        }

        return $this;
    }
264099
private static function createFromFileByMime($path)
    {
        $mime = File::getMimeType($path);
        switch ($mime) {
            case 'image/jpeg':
                $img = imagecreatefromjpeg($path);
                break;
            case 'image/gif':
                $img = imagecreatefromgif($path);
                break;
            case 'image/png':
                $img = imagecreatefrompng($path);
                break;
            default:
                throw new \Exception('can`t create thumbnail: unknown image type');
        }

        if ( ! $img) {
            throw new \Exception('can`t create thumbnail: can`t create image handle from file ' . $path);
        }

        return $img;
    }
1124736
public function createFolder($path)
    {
        $this->setupRequest([
            'path' => $this->normalizePath($path),
        ]);

        $this->apiEndpoint = 'files/create_folder';

        $response = $this->doDropboxApiRequest();
        $response['.tag'] = 'folder';

        return $response;
    }
1287888
public static function fromFile($path) {

        if(!is_file($path) || !is_readable($path)) {

            throw new TempFileException(sprintf('File %s does not exist or is not readable.', $path));
        }

        $tempFile = new static();
        $tempFile->closeFileHandle();

        if(!copy($path, $tempFile->filePath)) {

            throw new TempFileException(sprintf('Could not read in file %s.', $path));
        }

        $tempFile->openFileHandle('r+');

        return $tempFile;
    }
1340148
protected function createFileEntity($path) {
    $uri = $this->fileUnmanagedCopy($path);
    $file = $this->entityTypeManager->getStorage('file')->create([
      'uri' => $uri,
      'status' => 1,
    ]);
    $file->save();
    $this->storeCreatedContentUuids([$file->uuid() => 'file']);
    return $file->id();
  }
510588
public function save($path = null)
    {
        if (is_null($path)) {
            $path = $this->file;
        }
        imagejpeg($this->image, $path);
        return $this;
    }
1238175
public static function fromFile($path)
    {
        /** @var self $message */
        $message = static::fromString(join(PHP_EOL, file($path, FILE_IGNORE_NEW_LINES)));
        return $message;
    }
673671
public function makeDirectory($path)
    {
        event(new Events\DirectoryCreating($path));
        $created = $this->disk()->makeDirectory($path);
        event(new Events\DirectoryCreated($path, $created));

        return $created;
    }
809848
public function createFile($path, $contents)
    {
        $path = str_replace(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $path);

        $this->_io->out();

        $fileExists = is_file($path);
        if ($fileExists && empty($this->params['force']) && !$this->interactive) {
            $this->_io->out('<warning>File exists, skipping</warning>.');

            return false;
        }

        if ($fileExists && $this->interactive && empty($this->params['force'])) {
            $this->_io->out(sprintf('<warning>File `%s` exists</warning>', $path));
            $key = $this->_io->askChoice('Do you want to overwrite?', ['y', 'n', 'a', 'q'], 'n');

            if (strtolower($key) === 'q') {
                $this->_io->out('<error>Quitting</error>.', 2);
                $this->_stop();

                return false;
            }
            if (strtolower($key) === 'a') {
                $this->params['force'] = true;
                $key = 'y';
            }
            if (strtolower($key) !== 'y') {
                $this->_io->out(sprintf('Skip `%s`', $path), 2);

                return false;
            }
        } else {
            $this->out(sprintf('Creating file %s', $path));
        }

        $File = new File($path, true);

        try {
            if ($File->exists() && $File->writable()) {
                $File->write($contents);
                $this->_io->out(sprintf('<success>Wrote</success> `%s`', $path));

                return true;
            }

            $this->_io->err(sprintf('<error>Could not write to `%s`</error>.', $path), 2);

            return false;
        } finally {
            $File->close();
        }
    }
1104409
public static function loadDotFile($path)
    {
        $file = file_get_contents($path);
        if ($file === false) {
            return null;
        }

        $file = str_replace("\r", "\n", $file);      // Turn CR into LF
        $file = str_replace("\n\n", "\n", $file);   // Turn LFLF into LF
        $lines = explode("\n", $file);

        $data = [];

        $lineCount = count($lines);

        for ($i = 0; $i < $lineCount; $i++) {
            $line = trim($lines[$i]);
            if (strlen($line) === 0) {
                continue;
            }

            $split = explode('=', $line, 2);
            if (count($split) < 2) {
                throw new Exception\ConfigurationException("Invalid data in .bitrank file on line $i. ($line)");
            }

            $key = $split[0];
            $value = $split[1];

            $data[$key] = $value;
        }

        return $data;
    }
1208957
public function create($path)
    {
        if (preg_match('{^([a-zA-Z]):}', $path)) {
            return $this->windowsFactory()->create($path);
        }

        return $this->unixFactory()->create($path);
    }
549059
public function url($path = null)
    {
        $config = $this->make('flarum.config');
        $url = array_get($config, 'url', array_get($_SERVER, 'REQUEST_URI'));

        if (is_array($url)) {
            if (isset($url[$path])) {
                return $url[$path];
            }

            $url = $url['base'];
        }

        if ($path) {
            $url .= '/'.array_get($config, "paths.$path", $path);
        }

        return $url;
    }