Recursively find the last modified time under given path by file.

@param string  $path
@param string  $extensions   which files to search for specifically

@return int
556632
public static function lastModifiedFile($path, $extensions = 'md|yaml')
    {
        $last_modified = 0;

        /** @var UniformResourceLocator $locator */
        $locator = Grav::instance()['locator'];
        $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
        if ($locator->isStream($path)) {
            $directory = $locator->getRecursiveIterator($path, $flags);
        } else {
            $directory = new \RecursiveDirectoryIterator($path, $flags);
        }
        $recursive = new \RecursiveIteratorIterator($directory, \RecursiveIteratorIterator::SELF_FIRST);
        $iterator = new \RegexIterator($recursive, '/^.+\.'.$extensions.'$/i');

        /** @var \RecursiveDirectoryIterator $file */
        foreach ($iterator as $filepath => $file) {
            try {
                $file_modified = $file->getMTime();
                if ($file_modified > $last_modified) {
                    $last_modified = $file_modified;
                }
            } catch (\Exception $e) {
                Grav::instance()['log']->error('Could not process file: ' . $e->getMessage());
            }
        }

        return $last_modified;
    }
1123258
public function getTimestamp($path)
    {
        $stat = $this->getMetadata($path);

        return isset($stat['ctime']) ? ['timestamp' => $stat['ctime']] : false;
    }
661298
public function getCurrentDepth($path)
    {
        $parts = $this->getMagePathParts($path);
        return $parts !== false ? count($parts) : -1;
    }
1245344
public function isExpired( $path )
	{
		$compiled = $this->getCompiledPath( $path );

		// If the compiled file doesn't exist we will indicate that the view is expired
		// so that it can be re-compiled. Else, we will verify the last modification
		// of the views is less than the modification times of the compiled views.
		if ( !$this->files->exists( $compiled ) )
		{
			return true;
		}

		$lastModified = $this->files->lastModified( $path );

		return $lastModified >= $this->files->lastModified( $compiled );
	}
896195
private function getFilesMaxAge($path, $names = array(), $default = 0)
    {
        $finder = new Finder();
        $finder->files()->in(realpath($path))->ignoreDotFiles(true);
        foreach ($names as $name) {
            $finder->name($name);
        }
        $ages = array();
        foreach ($finder as $file) {
            $ages[] = filemtime($file);
        }
        return max(array_merge($ages, array($default)));
    }
255774
private function isUpdated($files)
	{
		$LastUpdate = 0;
		$basePath = $this->basePath;
		if(!empty($files))
		foreach($files as $file){
			$ed = filemtime($basePath.$file);
			if($ed > $LastUpdate){ $LastUpdate = $ed; }
		}
		return $LastUpdate;

	}
1090086
public static function get_time($path, $type = 'modified', $area = null)
	{
		$path = static::instance($area)->get_path($path);

		if ( ! file_exists($path))
		{
			throw new \InvalidPathException('Path: "'.$path.'" is not a directory or a file, cannot get creation timestamp.');
		}

		if ($type === 'modified')
		{
			return filemtime($path);
		}
		elseif ($type === 'created')
		{
			return filectime($path);
		}
		else
		{
			throw new \UnexpectedValueException('File::time $type must be "modified" or "created".');
		}
	}
481208
private function getPhpFilesFromPath(string $path)
    {
        $directoryIterator = new RecursiveDirectoryIterator($path);
        foreach (new RecursiveIteratorIterator($directoryIterator) as $file) {
            if (! in_array($file->getExtension(), $this->fileExtensions)) {
                continue;
            }

            if ($this->fileShouldBeIgnored($file)) {
                continue;
            }

            $this->files->push(new File(['displayPath' => $file->getPathName(), 'fullPath' => $file->getRealPath()]));
        }
    }
1147972
private function getLastMod($dirPath)
  {
    $dirInfo = new \SplFileInfo($dirPath);
    $lastMod = $dirInfo->getMTime();

    // Check files and subdirectories
    $iter = new \FilesystemIterator($dirPath);
    foreach ($iter as $fileInfo) {

      if ($fileInfo->isDir()) {
        $mtime = self::getLastMod($fileInfo->getPathname());
      }
      else {
        $mtime = $fileInfo->getMTime();
      }

      if ($mtime > $lastMod) {
        $lastMod = $mtime;
      }
    }

    return $lastMod;
  }
42007
public function time( $path )
	{
		try {
			return $this->fs->lastModified( $path );
		} catch( \Exception $e ) {
			throw new Exception( $e->getMessage(), 0, $e );
		}
	}
1254142
public function locate($path, $paths = null)
    {
        $paths = $paths ?: $this->getOption('paths');

        return $this->locator->locate(
            $path,
            $paths,
            $this->getOption('extensions')
        );
    }
850920
public function files(String $path, String $extension = NULL) : Array
    {
        $list = ftp_nlist($this->connect, $path);

        if( ! empty($list) ) foreach( $list as $file )
        {
            if( $file !== '.' && $file !== '..' )
            {
                if( ! empty($extension) && $extension !== 'dir' )
                {
                    if( Filesystem::getExtension($file) === $extension )
                    {
                        $files[] = $file;
                    }
                }
                else
                {
                    if( $extension === 'dir' )
                    {
                        $extens = Filesystem::getExtension($file);

                        if( empty($extens) )
                        {
                            $files[] = $file;
                        }
                    }
                    else
                    {
                        $files[] = $file;
                    }
                }
            }
        }

        if( ! empty($files) )
        {
            return $files;
        }
        else
        {
            return [];
        }
    }
1317438
public function &get($path = '')
  {
    $this->_tmp = &$this->_current;
    $this->_shiftTmp($path);
    return $this->_tmp;
  }
933718
public static function getDate($path)
    {
        if ($path[0] != "/") {
            $path = Env::path($path, Env::PATH_DOCUMENT_ROOT);
        }

        if (!$exif = exif_read_data($path)) {
            return;
        }

        if (empty($exif["DateTime"])) {
            return;
        }

        if (!$date = strtotime($exif["DateTime"])) {
            return;
        }

        return $date;
    }
235012
private function getFileExtension($path) {
		if (empty($path)) return '';
		$ext = pathinfo($path, PATHINFO_EXTENSION);
		return strtolower($ext); 
	}
945211
protected function scanDirectory($path, $extensions)
    {
        if (is_file($path)) {
            $file = new \SplFileInfo($path);
            return array($this->getFileKey($file->getPath(), $file) => $file);
        }
        
        $files = array();
        $extensions = (array) $extensions;
        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator(
                $path, 
                \FileSystemIterator::SKIP_DOTS 
                    | \FileSystemIterator::CURRENT_AS_FILEINFO)    
        );
        foreach ($iterator as $file) {
            if (in_array($file->getExtension(), $extensions)) {
                $files[$this->getFileKey($path, $file)] = $file;
            }
        }
        return $files;
    }
1212470
public function getFilesWithExtension($path, $ext = 'php')
    {
        if (is_dir($path)) {
            return new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
            ), '/^.+\.'.$ext.'$/i', RecursiveRegexIterator::GET_MATCH);
        } else {
            return [];
        }
    }