comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not>
Subject: Re: Using "pure" (?) Ada, how to determine whether a file is a "text" file, not a binary?
Date: Sat, 1 Jul 2023 22:39:27 +0200	[thread overview]
Message-ID: <u7q2tv$2u2pl$1@dont-email.me> (raw)
In-Reply-To: <41a5cad2-b5ca-4996-b057-e1ae8b27f526n@googlegroups.com>

On 2023-07-01 19:15, Kenneth Wolcott wrote:
> 
>    Using "pure" (?) Ada, how to determine whether a file is a "text" file, not a binary?

That depends on the definition of a text file. Under Unix and Windows, all files 
are sequences of bytes, and so may be considered sequences of Characters, and so 
text files.

If you can define what distinguishes text files from binary files, then it 
should be fairly easy to write Ada to distinguish them.

For example, if a text file is one in which all the characters, except line 
terminators, are graphic characters, then it should be clear how to determine 
whether a file meets that definition of a text file.

>    As a side question, how does one read "binary" files in Ada?

Ada has Direct_IO, Sequential_IO, and Stream_IO for reading binary files. Which 
you would use and how to use it depends on what's in the file and what you need 
to do with it.

-- 
Jeff Carter
"Ada is the only language where users are
happy to have compilation errors!"
Jean-Pierre Rosen
166

  reply	other threads:[~2023-07-01 20:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-01 17:15 Using "pure" (?) Ada, how to determine whether a file is a "text" file, not a binary? Kenneth Wolcott
2023-07-01 20:39 ` Jeffrey R.Carter [this message]
2023-07-01 20:54   ` Kenneth Wolcott
2023-07-01 21:39     ` Keith Thompson
2023-07-01 21:50       ` Kenneth Wolcott
2023-07-02  1:08         ` Chris Townley
2023-07-02  1:48           ` Kenneth Wolcott
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox