Checks if a file is apparently javascript compatible (.js or .coffee).

@param  String  file  Path to the file to test
@return Boolean
485912
function isJsFile(file) {
    "use strict";
    var ext = fileExt(file);
    var valid = Object.keys(require.extensions).map(function(val) {
        return val.replace(/^\./, '');
    }).filter(function(ext) {
        return ext === 'js' || ext === 'coffee';
    });
    return isString(ext, "string") && valid.indexOf(ext) !== -1;
}
1052827
protected function fileIsInExcludedPath($file)
    {
        $excludedPaths = [
            '/vendor/laravel/framework/src/Illuminate/Database',
            '/vendor/laravel/framework/src/Illuminate/Events',
            '/vendor/barryvdh/laravel-debugbar',
        ];

        $normalizedPath = str_replace('\\', '/', $file);

        foreach ($excludedPaths as $excludedPath) {
            if (strpos($normalizedPath, $excludedPath) !== false) {
                return true;
            }
        }

        return false;
    }
660538
function isJavaScriptFile(filepath) {
  if (!fs.statSync(filepath).isFile()) {
    return false;
  }
  if (path.basename(filepath) === 'index.js') {
    return false;
  }
  return filepath.slice(-3) === '.js';
}
411798
public function allowed($file)
    {
        return in_array($file->getType(), array('file', 'dir')) && $file->isReadable() && !$this->isInitialPath($file);
    }
821984
public function detectFalsyFunction(): bool
    {
        $file = file_get_contents($this->path);

        if (preg_match('/&warn\.deprecated\.function-(\d+-\d+-\d+)\.removed-(\d+-\d+-\d+)/', $file, $matches)) {
            $removedVersion = $matches[2];
            [$major, $minor] = explode('-', $removedVersion);
            if ($major < 7 || ($major == 7 && $minor == 0)) {
                // Ignore function if it was removed before PHP 7.1
                return false;
            }
        }
        if (preg_match('/&warn\.removed\.function-(\d+-\d+-\d+)/', $file, $matches) && isset($matches[2])) {
            $removedVersion = $matches[2];
            [$major, $minor] = explode('-', $removedVersion);
            if ($major < 7 || ($major == 7 && $minor == 0)) {
                // Ignore function if it was removed before PHP 7.1
                return false;
            }
        }

        if (preg_match('/&false;\s+on\s+error/m', $file)) {
            return true;
        }
        if (preg_match('/&false;\s+on\s+failure/m', $file)) {
            return true;
        }
        if (preg_match('/&false;\s+otherwise/m', $file) && !preg_match('/(returns\s+&true;|&true;\s+on\s+success|&true;\s+if)/im', $file)) {
            return true;
        }
        if (preg_match('/may\s+return\s+&false;/m', $file) && !preg_match('/(returns\s+&true;|&true;\s+on\s+success|&true;\s+if)/im', $file)) {
            return true;
        }
        if (preg_match('/&false;\s+if\s+an\s+error\s+occurred/m', $file)) {
            return true;
        }
        if (preg_match('/&return.success;/m', $file)) {
            return true;
        }
        if (preg_match('/&return.nullorfalse;/m', $file)) {
            return true;
        }
        if (preg_match('/&return.falseforfailure;/m', $file)) {
            return true;
        }
        if (preg_match('/&date.datetime.return.modifiedobjectorfalseforfailure;/m', $file)) {
            return true;
        }
        if (preg_match('/ or &false; \\(and generates an error/m', $file)) {
            return true;
        }
        if (preg_match('/&false;\s+if\s+the\s+number\s+of\s+elements\s+for\s+each\s+array\s+isn\'t\s+equal/m', $file)) {
            return true;
        }
        if (preg_match('/If\s+the\s+call\s+fails,\s+it\s+will\s+return\s+&false;/m', $file)) {
            return true;
        }
        if (preg_match('/Upon\s+failure,?\s+\<function\>[\w_]{1,15}?\<\/function\>\s+returns\s+&false;/m', $file)) {
            return true;
        }

        return false;
    }
790974
function fileExists(file) {
    try {
        var targetStat = fs.statSync(file);
        if (targetStat.isDirectory() ) {
            throw new Error("File exists but it's a driectory: " + file);
        }
    }
    catch(err) {
        if (err.code == 'ENOENT') {         // No such file or directory
            return false;
        }
        else {
            throw err;
        }
    }
    return true;
}
831593
public static function available(String $file) : Bool
    {
        $file = self::rpath($file);

        if( file_exists($file) )
        {
            return true;
        }

        return false;
    }
1117070
private function getType(string $file): string
	{
		$css = '/\.(css|less)$/';
		$js = '/\.js$/';

		if (preg_match($css, $file)) {
			return self::CSS;
		} elseif (preg_match($js, $file)) {
			return self::JS;
		}
		throw new InvalidArgumentException("Unknown assets file '$file'");
	}
635115
private function check($file)
    {
        /* 文件上传失败，捕获错误代码 */
        if ($file['error']) {
            $this->error($file['error']);

            return false;
        }
        /* 无效上传 */
        if (empty($file['name'])) {
            $this->error = '未知上传错误！';
        }
        /* 检查是否合法上传 */
        if (!is_uploaded_file($file['tmp_name'])) {
            $this->error = '非法上传文件！';

            return false;
        }
        /* 检查文件大小 */
        if (!$this->checkSize($file['size'])) {
            $this->error = '上传文件大小不符！';

            return false;
        }
        /* 检查文件Mime类型 */
        //TODO:FLASH上传的文件获取到的mime类型都为application/octet-stream
        if (!$this->checkMime($file['type'])) {
            $this->error = '上传文件MIME类型不允许！';

            return false;
        }
        /* 检查文件后缀 */
        if (!$this->checkExt($file['ext'])) {
            $this->error = '上传文件后缀不允许';

            return false;
        }

        /* 通过检测 */

        return true;
    }
241010
private function validateExecutable($file)
    {
        if (!file_exists($file) || !is_executable($file)) {
            throw new InvalidExecutableException(sprintf('File does not exist or is not executable: %s', $file));
        }

        return true;
    }
325615
private static boolean isJarFile(File file) {
		if (false == FileUtil.isFile(file)) {
			return false;
		}
		return file.getPath().toLowerCase().endsWith(".jar");
	}
1190797
public static function exists(string $file = ''): bool
    {
        $file = static::normalizePath($file);
        return static::verifyPath($file) && \file_exists($file) && \is_file($file);
    }
517509
protected function checkFileExistence(/*# string */ $file)
    {
        if (!file_exists($file) || !is_readable($file)) {
            throw new NotFoundException(
                Message::get(Message::DEFINITION_NOT_FOUND, $file),
                Message::DEFINITION_NOT_FOUND
            );
        }
    }
743462
public boolean accept(File file) {
    Matcher m = pattern.matcher(file.getName());
    return m.matches();
  }
477348
final private static function _hasFileKeys(Array $file): Bool
	{
		$valid = true;
		foreach(['error', 'tmp_name', 'type', 'size', 'name'] as $key) {
			if (! array_key_exists($key, $file)) {
				$valid = false;
				break;
			}
		}
		return $valid;
	}
136387
public function AcceptCheck($file = '') {
        if (!F("present")) {
            #获取当下文件目录结构
            $present = $this->get_dir_list();
            F("present", to_json($present));
        }
        $residue = $this->CloneSpy($file['check'], $file['delete']);
        $upload  = $this->getLocalFile($residue['local']);
        $data    = array(
            "url"    => $this->domain() . "/this7.php?type=download",
            "save"   => $upload,
            "update" => $residue['line'],
            "delete" => $residue['delete'],
        );
        $url = $file['url'];
        return $this->httpPost($url, $data);
    }
46334
protected function isValidFile($file): bool
    {
        // If there's no file we can't do anything with it...
        if (empty($file)) {
            return false;
        }

        // If the file doesn't exist, no need to try and get it.
        if (!file_exists($file)) {
            // We should probably log here...
            return false;
        }

        // If we can't read the file... Why try...
        if (!is_readable($file)) {
            // We should probably log or something here...
            return false;
        }

        return true;
    }