Load files from a given directory.
@param $data_folder string | The folder name.
@return array
431317
public function load($data_folder = '', $pages_data = '')
  {
    $this->data_path = '/' . $pages_data;
    $files = $this->read_dir($data_folder . $this->data_path);

    $pattern = '/(.+).json$/';

    $data_loader = new DataLoader();

    foreach($files as $file) {
      if (preg_match($pattern, $file, $match)) {
        $f = $data_loader->load(
          $data_folder . $this->data_path,
          $file
        );
        $f['file'] = $file;
        $this->files[] = $f;
      }
    }
  }
103625
public function getFoldersArray()
    {
        if ($this->_foldersArray === null) {
            $query = (new Query())
                ->from('{{%admin_storage_folder}} as folder')
                ->select(['folder.id', 'name', 'parent_id', 'timestamp_create', 'COUNT(file.id) filesCount'])
                ->where(['folder.is_deleted' => false])
                ->orderBy(['name' => 'ASC'])
                ->leftJoin('{{%admin_storage_file}} as file', 'folder.id=file.folder_id AND file.is_deleted = 0')
                ->groupBy(['folder.id'])
                ->indexBy(['id']);

            $this->_foldersArray = $this->getQueryCacheHelper($query, self::CACHE_KEY_FOLDER);
        }

        return $this->_foldersArray;
    }
657369
public function loadFromDirectory($path)
    {
        return $this->file->listFiles($path)->mapWithKeys(function ($file, $key) {
            return [$key => $this->loadFile($file)];
        });
    }
1115255
public function getFiles(array $dir_files, $files = array())
    {
        foreach ($dir_files as $file) {
            $filepath = $this->getFileManager()->DirTrim($this->getFileManager()->getDir(), $file, true);

            //Only show non-hidden files
            if ($file[0] != ".") {
                $files[] = new FileInfo($filepath, $this->getFileManager());
            }
        }
        return $files;
    }
284030
public static function loadPHPfolders($directory, $skipped=[]) {
		$loading = new \Lib\Loading();
		$loading->loadPHPfiles($directory, $skipped);
		
		$content = scandir($directory);
		foreach($content as $folder) {
			$defaults = [".", ".."];
			if(in_array($folder, $defaults) || in_array($folder, $skipped) || is_file($directory."/".$folder)) {
				continue;
			} else {
				$loading->loadPHPfiles($directory."/".$folder, $skipped);
			}
		}
	}
469758
public function load_controllers($root, $folder = null)
    {
        $current = $root . ($folder ? '/' . $folder : '');
        if (is_dir($current)) {
            $files = scandir($current);
            foreach ($files as $file) {
                if ($file != '.' && $file != '..') {
                    $filename = $current . '/' . $file;
                    $name = $folder . '/' . $file;
                    $ext = substr($file, strrpos($file, '.'));
                    if ($ext == '.php') {
                        if(($class = $this->preCache($filename)) === false) {
                            $class = file_get_php_classes($filename);
                            $this->postCache($filename, $class);
                        }
                        if(count($class) != 0) {
                            $this->controllers[$class[0]] = $folder . '/' . $file;
                            $this->controllers_map[$class[0]] = $root . '/' . $folder . '/' . $file;
                        } else {
                            Log::w($filename . " is not a valid controller!");
                        }
                    } elseif (is_dir($filename)) {
                        $this->load_controllers($root, $name);
                    }
                }
            }
        }
    }
146839
protected function scanFiles($current_directory)
    {
        $files = collect(Storage::files($current_directory));
        $files = $files->filter(function ($file) {
            $ext = File::extension($file);

            if ($this->filter === 'images') {
                return in_array($ext, $this->config->get('media.images_ext'));
            } elseif ($this->filter === 'files') {
                return in_array($ext, $this->config->get('media.files_ext'));
            }

            return true;
        });

        return $files;
    }
1178541
public function loadFile($file_name, $dir_name = null)
    {
        try {
            $loader = $this->getLoader();
            $file_path = $loader->findLanguageDBFile(
                !empty($file_name) ? basename($file_name) : $file_name,
                !empty($dir_name) ? $dir_name : (
                    !empty($file_name) ? dirname($file_name) : $dir_name
                )
            );
            if ($file_path && file_exists($file_path)) {
                $loader
                    ->setOption('language_strings_db_directory', dirname($file_path))
                    ->setOption('language_strings_db_filename', basename($file_path))
                ;

                $this->_loadLanguageStrings(true, true, true);
            } else {
                throw new I18nInvalidArgumentException(
                    sprintf('Language file "%s" not found!', $file_name)
                );
            }
        } catch (I18nException $e) {
            throw $e;
        }
    }
422647
public function getDirectories() : array
    {
        if(!$this->_isLoaded) {
            $this->load();
        }

        return array_map(function($directory) {
            return new Directory($this->getPath(). DIRECTORY_SEPARATOR .$directory);
        }, $this->_directories);
    }
967439
public function load() {
		// Create our array to return
		$return_array = array();

		// Did we pass a directory or file
		if ( is_readable( $this->directory ) ) {
			// Is our passed directory really a file?
			if ( is_file( $this->directory ) ) {
				// Add our returned array to our "return_array"
				$return_array = $return_array + $this->load_array_from_file( $this->directory );
			}
			// Must be a directory
			else {
				// Load our file list
				$file_list = $this->load_file_list( $this->directory, $this->ignore_prefix );

				// Loop through each file in our list
				foreach( $file_list as $file ) {
					// Add our returned array to our "return_array"
					$return_array = $return_array + $this->load_array_from_file( $file, $this->directory );
				}
			}
		}
		else {
			// Throw an exception
			throw new RuntimeException( 'Unable to read file/directory ' . $this->directory );
		}

		return $return_array;
	}
787542
private function loadFiles(): array
    {
        $items = [];
        if (!is_dir($this->path)) {
            return $items;
        }

        $entries = Finder::create()->files()->name('*.php')->in($this->path);

        // Load files.
        foreach ($entries as $entry) {
            $basename = call_user_func([$entry, 'getBasename']);

            if ($this->isEnvironmentFilename($basename)) {
                // Do not process this file. It will be handled later.
                continue;
            }

            $pathRelative = call_user_func([$entry, 'getRelativePath']);
            $configKey = rtrim($basename, '.php');

            // Load main config-file.
            $this->loadFile($items, $this->path, $pathRelative, $configKey);

            // Load environment config-file.
            $this->loadFile($items, $this->path, $pathRelative, $configKey, $this->environment);
        }

        return $items;
    }
866366
protected function load_file_list( $directory, $ignore_prefix ) {
		// Get an array of all of the files in the config directory
		$found_files = scandir( $directory );

		// Create an array to return
		$valid_files = array();

		foreach( $found_files as $file ) {
			// Is it a valid file?
			if ( is_file( $directory . $file ) && ( strpos( $file, $ignore_prefix ) !== 0 ) ) {
				$valid_files[] = $file;
			}
		}

		return $valid_files;
	}
275731
function _load()
    {
        $file = $this->_getFilePath();
        if (! file_exists($file) )
            ## nothing to import, no data written yet!
            return;

        ErrorStack::handleError(E_ALL);
        ##  \\\\\
        $data = include $file;
        $data = $this->getDataInterchange()->retrieveBackward($data);
        ##  /////
        if ( $exception = ErrorStack::handleDone() )
            throw new exReadError('Error While Read Data.', $exception->getCode(), $exception);


        if (! is_array($data) )
            throw new exDataMalformed('Error Data Structure, it must be array.');

        $this->data = $data;
    }
457651
private function load_config_file( $dir, $name ) {
		$path = rtrim( $dir, DS ) . DS . $name . '.php';
		if ( ! file_exists( $path ) ) {
			return [];
		}
		/** @noinspection PhpIncludeInspection */
		$config = include $path;
		if ( ! is_array( $config ) ) {
			$config = [];
		}

		return $config;
	}
925365
public function loadPhpFiles($dir)
    {
        $files = Finder::create()->files()->name('*.php')->in($dir);
        foreach ($files as $file) {
            $this->loadFile($file->getRealpath());
        }

    }
243236
def load_file(data_file):
    """"""
    try:
        with open(data_file, 'r', encoding='utf-8') as f:
            return json.loads(f.read())

    except JSONDecodeError as e:
        return []
1305442
public static function getFiles()
    {
        if (self::$_files === null) {
            self::$_files = [];
            if (isset($_FILES) && is_array($_FILES)) {
                foreach ($_FILES as $class => $info) {
                    self::getUploadFilesRecursive($class, $info['name'], $info['error']);
                }
            }
        }
        return self::$_files;
    }