Test if a file is a text file?

S

stephen O'D

Guys,

In Perl I can test if a file is a text file using the -T operator. Is
there a way to do the same thing in Ruby?

I know that File.file? tests for a plain file. I also came across
test('f', 'filename') which does the same thing, but doesn't accept T
as a parameter.

Any pointers are greatly appreciated!

Thanks,

Stephen.
 
C

Chris Shea

Guys,

In Perl I can test if a file is a text file using the -T operator. Is
there a way to do the same thing in Ruby?

I know that File.file? tests for a plain file. I also came across
test('f', 'filename') which does the same thing, but doesn't accept T
as a parameter.

Any pointers are greatly appreciated!

Thanks,

Stephen.

This has come up a few times before on this list. You could search
the archives:
http://groups.google.com/group/comp...=perl+text+binary+file&qt_g=Search+this+group

You'll find that every once in a while someone posts code to do what
Perl does:
http://groups.google.com/group/comp...perl+text+binary+file&rnum=2#9ac698f82c6c0496

There's an awful lot of discussion about this, very handily indexed by
search engines.

HTH,
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,311
Members
47,981
Latest member
satome

Latest Threads

Top