ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Clark" <robert.cl...@quest.com>
Subject Re: Testing a file if it is binary or not.
Date Tue, 21 Aug 2007 19:20:04 GMT
On Monday August 20, 2007, "David Weintraub" <qazwart@gmail.com> 
wrote:
> I would use a Perl script to read the first 8000 or so bytes of a
> file and look for characters outside of what you'd expect to be
> ASCII range.

Using Perl, the -T (for text) and -B (for binary) flags do pretty much 
exactly that and work really well. For example:

$myfile = "some.file"

if ( -B "$myfile" ) {
    # file is binary
}
else {
    # file is text
}

- Rob





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message