WC_Product_CSV_Importer_Controller::file_is_in_directory()private staticWC 1.0

Check if a given file is inside a given directory.

Method of the class: WC_Product_CSV_Importer_Controller{}

No Hooks.

Return

true|false. True if the file is inside the directory.

Usage

$result = WC_Product_CSV_Importer_Controller::file_is_in_directory( $file_path, $directory ): bool;
$file_path(string) (required)
The full path of the file to check.
$directory(string) (required)
The path of the directory to check.

WC_Product_CSV_Importer_Controller::file_is_in_directory() code WC 9.5.1

private static function file_is_in_directory( string $file_path, string $directory ): bool {
	$file_path = (string) new URL( $file_path ); // This resolves '/../' sequences.
	$file_path = preg_replace( '/^file:\\/\\//', '', $file_path );
	return 0 === stripos( wp_normalize_path( $file_path ), trailingslashit( wp_normalize_path( $directory ) ) );
}