Skip to content

Commit

Permalink
Determine files' mime type with mime_content_type
Browse files Browse the repository at this point in the history
  • Loading branch information
fpapadopou committed May 16, 2016
1 parent 05cc75c commit ee67d95
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,10 @@ public function fetchLibraryFiles($finder, $directory, $getContent = true)
// $finder->name('*.cpp')->name('*.h')->name('*.c')->name('*.S')->name('*.inc')->name('*.txt');
$finder->name('*.*');

$finfo = finfo_open(FILEINFO_MIME_TYPE);

$response = array();
foreach ($finder as $file) {
if ($getContent) {
$mimeType = finfo_file($finfo, $file);
$mimeType = mime_content_type($file->getRealpath());
if (strpos($mimeType, "text/") === false)
$content = "/*\n *\n * We detected that this is not a text file.\n * Such files are currently not supported by our editor.\n * We're sorry for the inconvenience.\n * \n */";
else
Expand Down

0 comments on commit ee67d95

Please sign in to comment.