MCPcopy Create free account
hub / github.com/cfinke/Channel-Two / files_in_dir_deep

Function files_in_dir_deep

parse-schedule.php:260–282  ·  view source on GitHub ↗

* Find all files in a given directory, including files within subfolders (and their subfolders, etc.) */

( $dir )

Source from the content-addressed store, hash-verified

258 * Find all files in a given directory, including files within subfolders (and their subfolders, etc.)
259 */
260function files_in_dir_deep( $dir ) {
261 $files_and_dirs = glob( rtrim( $dir, '/' ) . '/' . "*" );
262
263 $files = array();
264
265 foreach ( $files_and_dirs as $file_or_dir ) {
266 if ( file_exists( $file_or_dir ) ) {
267 if ( is_file( $file_or_dir ) ) {
268 $mime_type = mime_content_type( $file_or_dir );
269
270 if ( stripos( $mime_type, 'video/' ) === 0 ) {
271 $files[] = $file_or_dir;
272 }
273 } else {
274 $files = array_merge( $files, files_in_dir_deep( $file_or_dir ) );
275 }
276 } else {
277 echo "File does not exist: " . $file_or_dir . "\n";
278 }
279 }
280
281 return $files;
282}
283
284/**
285 * Find the duration in seconds of a given video file.

Callers 1

parse-schedule.phpFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected