Returns the most recent file in $path.
@param  string $path Where to look
@return string       Most recent file
335794
protected function getMostRecent($path)
    {
        $latestFilename = null;
        $latestCtime = 0;

        $d = dir($path);
        while (false !== ($entry = $d->read())) {
            $filepath = "{$path}/{$entry}";
            // could do also other checks than just checking whether the entry is a file
            if (is_file($filepath) && filectime($filepath) > $latestCtime) {
                $latestFilename = $entry;
            }
        }
        return $path . $latestFilename;
    }
370075
public function getFile($path)
    {
        $file = new File($this->getFileSystemId(), $this->getFullPath($path));
        $file->setServiceLocator($this->getServiceLocator());
        return $file;
    }
901155
protected function getXStream($path)
    {
        if ($this->getFilesystem()->has($path)) {
            trigger_error('fopen(): failed to open stream: File exists', E_USER_WARNING);

            return false;
        }

        $this->needsFlush = true;

        return fopen('php://temp', 'w+b');
    }
464769
public function lastModified($path)
	{
		$path = Util::normalizePath($path);

		return (int) $this->adapter->lastModified($path);
	}
554953
protected function _findPath($path)
    {
        $path = $this->_unifyPath($path);
        $dirs = $this->_dirs;

        $file = null;

        foreach ($dirs as $dir) {
            if (is_readable(realpath($dir.DS.$path))) {
                $file = $dir.DS.$path;
                break;
            }
        }

        return $file;
    }
1317438
public function &get($path = '')
  {
    $this->_tmp = &$this->_current;
    $this->_shiftTmp($path);
    return $this->_tmp;
  }
523074
public function fileModified($path)
    {
        try {
            return Carbon::createFromTimestamp($this->disk->lastModified($path));
        } catch (\Exception $e) {
            return Carbon::now();
        }
    }
1343618
protected function _getRelDir($path) {
        $filename = basename($path);
        $dir = substr($path, 0, strlen($path) - strlen($filename));
        return $dir;
    }
927374
protected function get_files( $path ) {
		$filtered_files = array();
		try {
			$files = new RecursiveIteratorIterator(
				new RecursiveDirectoryIterator(
					$path,
					RecursiveDirectoryIterator::SKIP_DOTS
				),
				RecursiveIteratorIterator::CHILD_FIRST
			);
			foreach ( $files as $file_info ) {
				$pathname = self::normalize_directory_separators( substr( $file_info->getPathname(), strlen( $path ) ) );
				if ( $file_info->isFile() && $this->filter_file( $pathname ) ) {
					$filtered_files[] = $pathname;
				}
			}
		} catch ( Exception $e ) {
			WP_CLI::error( $e->getMessage() );
		}

		return $filtered_files;
	}
278870
public function get(string $path): File {
		return (new File(Paths::appendPath($this->getUrl(), $path)))->addFilters($this->recursiveFilter, true);
	}
56536
protected function parseFile($path)
    {
        $content = $this->filesystem->readFile($path);

        return $this->parseContent($content, $path);
    }
255417
public function get($path)
    {
        $return = null;
        $path = \preg_split('#[./]#', $path);
        $depth = 0;
        while ($path) {
            $key = \array_shift($path);
            if ($depth == 0) {
                if ($key == 'currentPage') {
                    $return = $this->data['pages'][ $this->data['i'] ];
                } elseif ($key == 'nextI') {
                    foreach ($this->data['pages'] as $i => $page) {
                        if (!$page['completed']) {
                            return $i;
                        }
                    }
                // } elseif ($key == 'submitted') {
                    // return $this->data['submitted'];
                } elseif (isset($this->data[$key])) {
                    $return = $this->data[$key];
                } elseif (isset($this->data['persist'][$key])) {
                    $return = $this->data['persist'][$key];
                } else {
                    return null;
                }
            } elseif (isset($return[$key])) {
                $return = $return[$key];
            } else {
                return null;
            }
            $depth++;
        }
        return $return;
    }
622733
public function getFileHistory(FilePath $path, $maxCount = null)
    {
        return $this->gitService->getFileHistory($path, $maxCount);
    }
82774
private function _listFiles($path)
    {
        if ($this->isSFTP()) {
            $files = @$this->ftp->nlist($path);
        } else {
            $files = @ftp_nlist($this->ftp, $path);
        }
        if ($files === false) {
            $this->fail("couldn't list files");
        }
        return $files;
    }
630684
public function cleanDirectory($path)
    {
        $time = time();
        $maxFileAge = 3600;
        $files = (array) $this->files->files($path);
        foreach ($files as $file) {
            if ($this->files->isFile($file) === true &&
                $this->files->lastModified($file) < ($time - $maxFileAge)
            ) {
                $this->files->delete($file);
            }
        }

        return $this;
    }
317963
public static function getFolder(string $path)
    {
        $arrFolders = explode(DIRECTORY_SEPARATOR, $path);
        $fullPath = "";
        if ($arrFolders[0] !== "") {
            $fullPath = $arrFolders[0];
        }
        unset($arrFolders[0]);
        foreach ($arrFolders as $folder) {
            $fullPath .= DIRECTORY_SEPARATOR . $folder;
            if (file_exists($fullPath) && is_dir($fullPath)) {
                continue;
            }
            mkdir($fullPath, 0775);
        }
        return $path;
    }
867161
public function getUploadedFile($path)
    {
        $file = Hash::get($this->uploadedFiles, $path);
        if (!$file instanceof UploadedFile) {
            return null;
        }

        return $file;
    }