You are here

public static function SassFile::findFile in Sassy 7

* Looks for the file recursively in the specified directory. * This will also look for _filename to handle Sass partials. *

Parameters

string filename to look for: * @param string path to directory to look in and under * @return mixed string: full path to file if found, false if not

1 call to SassFile::findFile()
SassFile::getFile in phamlp/sass/SassFile.php
* Returns the full path to a file to parse. * The file is looked for recursively under the load_paths directories and * the template_location directory. * If the filename does not end in .sass or .scss try the current syntax first * then, if a…

File

phamlp/sass/SassFile.php, line 108

Class

SassFile
SassFile class. @package PHamlP @subpackage Sass

Code

public static function findFile($filename, $dir) {
  $partialname = dirname($filename) . DIRECTORY_SEPARATOR . '_' . basename($filename);
  foreach (array(
    $filename,
    $partialname,
  ) as $file) {
    if (file_exists($dir . DIRECTORY_SEPARATOR . $file)) {
      return realpath($dir . DIRECTORY_SEPARATOR . $file);
    }
  }
  $files = array_slice(scandir($dir), 2);
  foreach ($files as $file) {
    if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) {
      $path = self::findFile($filename, $dir . DIRECTORY_SEPARATOR . $file);
      if ($path !== false) {
        return $path;
      }
    }
  }

  // foreach
  return false;
}