/*
Check that given file is supported by this sequencer and find out the format.
547865
public boolean check() throws Exception {
        format = FORMAT_UNSUPPORTED;
        // create a temporary copy from input
        File fileCopy = File.createTempFile("modeshape-sequencer-audio", ".tmp");
        IoUtil.write(in, new BufferedOutputStream(new FileOutputStream(fileCopy)));

        if (mimeType.startsWith("audio/mpeg")) {
            format = FORMAT_MP3;
            audioFile = new MP3FileReader().read(fileCopy);
        } else if (mimeType.startsWith("audio/vorbis") || mimeType.startsWith("audio/x-vorbis") || mimeType.startsWith("audio/ogg")) {
            format = FORMAT_VORBIS;
            audioFile = new OggFileReader().read(fileCopy);
        } else if (mimeType.startsWith("audio/flac") || mimeType.startsWith("audio/x-flac")) {
            format = FORMAT_FLAC;
            audioFile = new FlacFileReader().read(fileCopy);
        } else if (mimeType.equals("audio/mp4") || mimeType.equals("video/mp4") || mimeType.equals("video/quicktime")) {
            format = FORMAT_MP4;
            audioFile = new Mp4FileReader().read(fileCopy);
        } else if (mimeType.equals("audio/x-ms-wma")) {
            format = FORMAT_WMA;
            audioFile = new AsfFileReader().read(fileCopy);
        } else if (mimeType.startsWith("audio/x-wav") || mimeType.startsWith("audio/wav")) {
            format = FORMAT_WAV;
            audioFile = new WavFileReader().read(fileCopy);
        }

        // try to delete the file immediately or on JVM exit
        boolean deleted = false;
        try {
            deleted = fileCopy.delete();
        } catch (SecurityException e) {
            // ignore
        }
        if (!deleted) {
            fileCopy.deleteOnExit();
        }
        return checkSupportedAudio();
    }
704591
@Override
	public boolean accept(final File file) {
		if (file != null) {
			if (file.isDirectory()) {
				return true;
			}

			final String extension = getExtension(file);
			if (extension != null && filters.containsKey(extension)) {
				return true;
			}
		}
		return false;
	}
1032966
public static boolean supportsStyle(String style) {
		String styleFileName = style;
		if (!styleFileName.endsWith(".csl")) {
			styleFileName = styleFileName + ".csl";
		}
		if (!styleFileName.startsWith("/")) {
			styleFileName = "/" + styleFileName;
		}
		URL url = CSL.class.getResource(styleFileName);
		return (url != null);
	}
160632
def _DetermineFormat(self):
    """"""
    if self._zip:
      # If zip was passed to __init__ then path isn't used
      assert not self._path
      return True

    if not isinstance(self._path, basestring) and hasattr(self._path, 'read'):
      # A file-like object, used for testing with a StringIO file
      self._zip = zipfile.ZipFile(self._path, mode='r')
      return True

    if not os.path.exists(self._path):
      self._problems.FeedNotFound(self._path)
      return False

    if self._path.endswith('.zip'):
      try:
        self._zip = zipfile.ZipFile(self._path, mode='r')
      except IOError:  # self._path is a directory
        pass
      except zipfile.BadZipfile:
        self._problems.UnknownFormat(self._path)
        return False

    if not self._zip and not os.path.isdir(self._path):
      self._problems.UnknownFormat(self._path)
      return False

    return True
743462
public boolean accept(File file) {
    Matcher m = pattern.matcher(file.getName());
    return m.matches();
  }
531875
protected function _isValidFormat()
	{
		// Read sample data (first 2 KB will do)
		$data = fread($this->_fileHandle, 2048);

		// Count delimiters in file
		$delimiterCount = substr_count($data, ';');
		if ($delimiterCount < 1) {
			return FALSE;
		}

		// Analyze first line looking for ID; signature
		$lines = explode("\n", $data);
		if (substr($lines[0],0,4) != 'ID;P') {
			return FALSE;
		}

		return TRUE;
	}
573088
function isImage(file) {
        var valid = true,
          // formats = _module.options.formats || ['csv', 'xls', 'zip', 'kml', 'kmz', 'gpx', 'lut', 'stl', 'dxf', 'txt', 'pdf', 'svg', 'doc', 'ppt', 'gif', 'png', 'jpg', 'jpeg'],
          formats = _module.options.formats || ["gif", "png", "jpg", "jpeg"],
          filetype = file.name.split(".")[file.name.split(".").length - 1];
        filetype = filetype.toLowerCase();
        if (formats.indexOf(filetype) === -1) valid = false;
        return valid;
      }
399122
@Deprecated
    public static boolean isSupportedImageFile(final String lcasefn) {
        for (final String ext: supportedImageExtensions) {
            if (lcasefn.endsWith(ext)) {
                return true;
            }
        }
        return false;
    }
135104
def find_file_format(file_name):
        
        for file_format in Format.ALLOWED:
            file_path = '.'.join((file_name, file_format))
            if os.path.exists(file_path):
                return file_path, file_format
        return None, None
78979
def guess_format( filename, ext, formats, io_table ):
    
    ok = False
    for format in formats:
        output( 'guessing %s' % format )
        try:
            ok = io_table[format].guess( filename )
        except AttributeError:
            pass
        if ok: break

    else:
        raise NotImplementedError('cannot guess format of a *%s file!' % ext)

    return format
673539
def detect_format(filename):
    
    filename = Path(filename)

    if filename.suffix == '.csv':
        recformat = 'csv'
    elif filename.suffix == '.sfp':
        recformat = 'sfp'

    else:
        recformat = 'unknown'

    return recformat
1344094
public static boolean isCharsetSupported (String charset){
        Boolean supported = (Boolean) supportedEncodingsCache.get(charset);
        if(supported != null){
            return supported.booleanValue();
        }
        try{
            new String (TEST_CHAR, charset);
            supportedEncodingsCache.put(charset, Boolean.TRUE);
        }catch (UnsupportedEncodingException e){
            if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {
                logger.logp(Level.FINE, CLASS_NAME,"isCharsetSupported", "Encountered UnsupportedEncoding charset [" + charset +"]");
            }
            supportedEncodingsCache.put(charset, Boolean.FALSE);
            return false;
        }
        return true;
    }
764761
function(file) {
      var type = file.type.toLowerCase(),
        sources = file.sources;

      $.each(sources, function(tmpSource) {
        if (_support[type][tmpSource]) {
          file = file.sources[tmpSource];
          file.type = type.toUpperCase();
          return false;
        }
      });
      if (file.source) {
        return file;
      } else {
        return false;
      }
    }
1170394
def isSupportedContent(cls, fileContent):
        """"""
        magic = bytearray(fileContent)[:4]
        return magic == p('>I', 0xfeedface) or magic == p('>I', 0xfeedfacf) or magic == p('<I', 0xfeedface) or magic == p('<I', 0xfeedfacf)
325537
public boolean accept(File file) {
        if (caseSensitive) {
            return file.getName().endsWith(string0);
        } else {
            return file.getName().toLowerCase().endsWith(string0.toLowerCase());
        }
    }
865096
public ResourceFormatGenerator getGeneratorForFileExtension(final String extension) throws
        UnsupportedFormatException {
        for (final ResourceFormatGenerator generator : listGenerators()) {
            if (generator.getFileExtensions().contains(extension)) {
                return generator;
            }
        }
        throw new UnsupportedFormatException("No provider available to parse file extension: " + extension);
    }
493991
protected function verifyFormatCompatiblity ()
	{
		$isCompatible 	= true;
		$gdInfo			= gd_info();
		
		switch ($this->format)
		{
			case 'GIF':
				$isCompatible = $gdInfo['GIF Create Support'];
				break;
			case 'JPG':
				$isCompatible = (isset($gdInfo['JPG Support']) || isset($gdInfo['JPEG Support'])) ? true : false;
				break;
			case 'PNG':
				$isCompatible = $gdInfo[$this->format . ' Support'];
				break;
			default:
				$isCompatible = false;
		}
		
		if (!$isCompatible)
		{
			// one last check for "JPEG" instead
			$isCompatible = $gdInfo['JPEG Support'];
			
			if (!$isCompatible)
			{
				$this->triggerError('Your GD installation does not support ' . $this->format . ' image types');
			}
		}
	}