File creation method.

@return File
543937
public function resolve()
    {
        $this->file = (new $this->fileClass())
            ->setName(
                $this->physicalFile->getBasename()
            )
            // calculate original name (keep it for user data display)
            ->setOriginalName($this->originalName
                ?: $this->physicalFile->getBasename()
            )
            // calculate storage path (we only need path from config)
            ->setStorePath(str_replace(// trim base path
                realpath($this->storePath),
                '',
                str_replace(// trim filename
                    $this->physicalFile->getBasename(),
                    '',
                    $this->physicalFile->getRealpath()
                )
            ))
        ;

        $this->assertEntityIsValid($this->file, array('File', 'creation'));

        $this->fireEvent(
            FileEvents::FILE_CREATED,
            new FileEvent($this->file, $this)
        );

        return $this->file;
    }
120000
protected function _createFile()
        {
            do {
                $this->_filename = $this->getPath() .  mt_rand() . '.html';
            } while(File::exists($this->_filename));

            /**
             * create an empty file
             */
            File::put($this->_filename, $this->getHtml());
            chmod($this->_filename, 0777);

            return $this->_filename;
        }
919439
public function createVersion()
    {
        if (!file_exists($this->owner->getFullPath())) {
            return false;
        }

        $version = new FileVersion();
        $version->FileID = $this->owner->ID;
        $version->write();

        $this->owner->CurrentVersionID = $version->ID;
        return (bool) $this->owner->write();
    }
1373588
protected function openFile() {
		$file = $this->getTargetFile();

		// Create the target folder if needed
		if(!is_file($file)) {
			$dir = dirname($file);

			if(!is_dir($dir)) {
				$success = \n2n\io\IoUtils::mkdirs($dir, 0777, true);
				if ($success === false) {
					$this->warn("Failed creating target directory [$dir]. Closing appender.");
					$this->closed = true;
					return false;
				}
			}
		}
		
		$mode = $this->append ? 'a' : 'w';
		$this->fp = \n2n\io\IoUtils::fopen($file, $mode);
		if ($this->fp === false) {
			$this->warn("Failed opening target file. Closing appender.");
			$this->fp = null;
			$this->closed = true;
			return false;
		}
		
		// Required when appending with concurrent access
		if($this->append) {
			\n2n\io\IoUtils::fseek($this->fp, 0, SEEK_END);
		}
		
		// Write the header
		$this->write($this->layout->getHeader());
	}
573682
protected function createFolderIfMissing()
    {
        if (!file_exists($this->webPath . '/' . $this->imageFolder)) {
            mkdir($this->webPath . '/' . $this->imageFolder, 0755);
        }
    }
1203584
public function initFile()
    {
        
    	if ($this->maxFileSize > 0 && file_exists($this->filename) && filesize($this->filename) >= $this->maxFileSize) {
	    	
	    	if ($this->compression == self::COMPRESSION_ZIP) {
	    		$zip = new ZipArchive;
				$res = $zip->open($this->getAvailableArchiveFileName(), ZipArchive::CREATE);
				if ($res === true) {
				    $zip->addFile($this->filename, basename($this->filename));
				    $zip->close();
				    unlink($this->filename);
				} else {
					//fail silently
					return false;
				}	
	    	} elseif ($this->compression == self::COMPRESSION_NONE) {
	    		$success = rename($this->filename, $this->getAvailableArchiveFileName());
	    		if (!$success) {
					//fail silently
					return false;
	    		}
	    	} else {
				//fail silently
				return false;
	    	}
    	}
    	$this->filehandle = @fopen($this->filename, 'a');
        

    }
344199
public function getFile(){
        if(!$this->isPropertyAvailable('File')){
            $this->setProperty("File", new File($this->getContext(),new ResourcePathEntity($this->getContext(),$this->getResourcePath(), "File")),false);
        }
        return $this->getProperty("File");
    }
629844
public function actionFileUpload() {

		$source = $this->config->getCompatibleSource($this->request->source);

		$root = $source->getRoot();
		$path = $source->getPath();

		$this->accessControl->checkPermission($this->getUserRole(), $this->action, $path);

		$messages = [];

		$files = $this->move($source);

		$isImages = [];
		$files = array_map(function (File $file) use ($source, $root, &$isImages) {
			$messages[] = 'File ' . $file->getName() . ' was uploaded';
			$isImages[] = $file->isImage();
			return str_replace($root, '', $file->getPath());
		}, $files);

		if (!count($files)) {
			throw new \Exception('No files have been uploaded', Consts::ERROR_CODE_NO_FILES_UPLOADED);
		}

		return [
			'baseurl' => $source->baseurl,
			'messages' => $messages,
			'files' => $files,
			'isImages' => $isImages
		];
	}
439314
public function createTarFileSet()
    {
        $this->fileset = new TarFileSet();
        $this->filesets[] = $this->fileset;

        return $this->fileset;
    }
875912
final public function createFile($filePath = null)
    {
        if (isset($filePath)) {
            $this->filePath = $filePath;
        }

        if (pathinfo($this->filePath, PATHINFO_EXTENSION) === '') {
            $this->filePath .= $this->fileExtension;
        }

        return $this;
    }
1211047
protected function getFilesystem()
	{
		if (!isset($this->filesystem)) {
			$this->filesystem = new Filesystem($this->getAdapter());
		}
		return $this->filesystem;
	}
1311773
protected function createMimetypeFile()
    {
        $this->createFileWithContents($this->rootFolder, self::MIMETYPE_FILE_NAME, self::MIMETYPE);
        return $this;
    }
1078539
public function createInputStream(): InputStream {
		$this->ensureValid();
		try {
			return IoUtils::createSafeFileInputStream($this->fsPath);
		} catch (CouldNotAchieveFlockException $e) {
			return new FileResourceStream($this->fsPath, 'r');
		}
	}
1102660
private static function file()
    {
        $files = ['File', 'Filesystem'];
        $folder = static::$root.'Filesystem'.'/';

        self::call($files, $folder);

        $files = ['FileNotFoundException', 'DirectoryNotFoundException'];
        $folder = static::$root.'Filesystem/Exceptions'.'/';

        self::call($files, $folder);
    }
528748
public function create() 
    {
        try {            
            $fileData['alias'] = Input::get('filename') ? Input::get('filename') : date('m.d.Y - G:i:s');
            $fileData['type'] = 'folder';
            if(Input::get('pid') > 0) {
                $fileData['parent_id'] = Input::get('pid');
            }
            
            $this->file->create($fileData);

            return response()->json([
                'status' => 'success'
            ]);
        }
        
        catch (Exception $e) {
            return $this->handleError($e);
        }
    }
968993
protected function createFileDriver()
    {
        $path = $this->app['config']['cache.path'];

        return $this->repository(new FileStore($this->app['files'], $path));
    }
651761
public function create()
    {
        if (! $this->adapter->fileExists($this->path, true)) {
            // ensure the parent directory exists
            new Directory(dirname($this->path), $this->adapter);

            if ($this->adapter->createFile($this->path) === false) {
                $this->throwUnableToCreate();
            }
        }

        return $this;
    }