@param  string  $file_path
@param  bool $create_directory

@return string
434347
private function getCacheLocationForPath($file_path, $create_directory = false)
    {
        $root_cache_directory = $this->config->getCacheDirectory();

        if (!$root_cache_directory) {
            throw new \UnexpectedValueException('No cache directory defined');
        }

        $parser_cache_directory = $root_cache_directory . DIRECTORY_SEPARATOR . self::FILE_STORAGE_CACHE_DIRECTORY;

        if ($create_directory && !is_dir($parser_cache_directory)) {
            mkdir($parser_cache_directory, 0777, true);
        }

        return $parser_cache_directory
            . DIRECTORY_SEPARATOR
            . sha1($file_path)
            . ($this->config->use_igbinary ? '-igbinary' : '');
    }
1226633
def __generate_file(self, file_path):
        
        file_path = os.path.expanduser(file_path)
        if not os.path.exists(os.path.dirname(file_path)):
            self.logger.debug("Directories missing! Creating directories for %s..." % file_path)
            os.makedirs(os.path.dirname(file_path))
        if not os.path.exists(file_path):
            open(file_path, "w+").close()
        return file_path
673671
public function makeDirectory($path)
    {
        event(new Events\DirectoryCreating($path));
        $created = $this->disk()->makeDirectory($path);
        event(new Events\DirectoryCreated($path, $created));

        return $created;
    }
52141
public function findRealPath($file_path)
    {
        if (@file_exists($file_path)) {
            return realpath($file_path);
        }
        if (@file_exists($this->web_root_path.$file_path)) {
            return $this->web_root_path.$file_path;
        }
        return null;
    }
722382
public function getFilesInDir($dir_path, array $file_extensions)
    {
        $file_paths = [];

        /** @var \RecursiveDirectoryIterator */
        $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir_path));
        $iterator->rewind();

        while ($iterator->valid()) {
            if (!$iterator->isDot()) {
                $extension = $iterator->getExtension();
                if (in_array($extension, $file_extensions, true)) {
                    $file_paths[] = (string)$iterator->getRealPath();
                }
            }

            $iterator->next();
        }

        return $file_paths;
    }
183567
def check_create_folder(folder_path):
    
    if not os.path.exists(folder_path):
        os.makedirs(folder_path)

    return folder_path
557912
public function getReportingLevelForFile($file_path)
    {
        foreach ($this->custom_levels as $custom_level) {
            if ($custom_level->allows($file_path)) {
                return $custom_level->getErrorLevel();
            }
        }

        return $this->error_level;
    }
974032
static function create_directory($directory_path, $perms = 0777)
    {
        echo ("Creating the directory: ".$directory_path.PHP_EOL);
        if (!file_exists($directory_path)) {
            mkdir($directory_path, $perms, true);
        } else {
            self::error_out('Error: directory already exists or cannot be written.');
        }
    }
164824
public function getFileContent($filePath, $createIfNotExists = false)
    {
        if ($createIfNotExists && ! $this->disk->exists($filePath)) {
            if (! $this->disk->exists($directory = dirname($filePath))) {
                mkdir($directory, 0777, true);
            }

            file_put_contents($filePath, "<?php\n\nreturn [];");

            return [];
        }

        try {
            return (array) include $filePath;
        } catch (\ErrorException $e) {
            throw new FileNotFoundException('File not found: '.$filePath);
        }
    }
574411
public function addFileToDeepScan($file_path)
    {
        $this->files_to_scan[$file_path] = $file_path;
        $this->files_to_deep_scan[$file_path] = $file_path;
    }
997472
def file_w_create_directories(filepath):
    
    dirname = os.path.dirname(filepath)

    if dirname and dirname != os.path.curdir and not os.path.isdir(dirname):
        os.makedirs(dirname)

    return open(filepath, 'w')
926435
public static function createFileDir($path)
    {
        if (!file_exists($path)) {
            self::createFileDir(dirname($path));
            mkdir($path, 0777);
        }
    }
529699
public static function autoCreateDirectory($path_name)
    {
        // check directory
        if (!File::exists(dirname($path_name))) {
            $isMadeDir = mkdir(dirname($path_name), 0777, true);
            if (!$isMadeDir) {
                return false;
            }
        }
        return true;
    }
219642
public function open(string $file_path, bool $check_avail_mem = true): bool
    {
        if (!file_exists($file_path)) {
            return false;
        }

        if (!($imgData = getimagesize($file_path))) {
            return false;
        }

        $this->image_width = (int)$imgData[0];
        $this->image_height = (int)$imgData[1];

        if ($check_avail_mem && !$this->haveEnoughMemoryToOpenAndProcess()) {
            throw new RuntimeException('Empty can not be opened.');
        }

        $image = false;
        switch ($this->image_type = $imgData[2]) {
            case '1':

                $image = imagecreatefromgif($file_path);

                break;

            case '2':

                $image = imagecreatefromjpeg($file_path);

                break;

            case '3':

                $image = imagecreatefrompng($file_path);

                break;
        }

        if ($image) {
            $this->image_resource = $image;

            return true;
        }

        return false;
    }
307839
function checkAndOrCreateDir($dir, $create = false, $perm = '0777')
    {
        if(is_dir($dir) && is_writable($dir)) return true;
        elseif($create === false) return false;

        @mkdir($dir, $perm, true);
        @chmod($dir, $perm);

        if(is_writable($dir)) return true;
        return false;
    }
1372266
protected function createFileDir($path)
    {
        if (!file_exists($path)) {
            $this->createFileDir(dirname($path));
            mkdir($path, 0777);
        }
    }
568093
protected function putIntoFile($file_path, $data)
    {
        if ($this->files->isDirectory($this->files->dirname($file_path))) {
            $data = str_replace(["\n", "\r"], '', trim((string) $data));

            return $this->files->put($file_path, $data, $this->use_locking) > 0;
        }

        // @codeCoverageIgnoreStart
        return false;
        // @codeCoverageIgnoreEnd
    }