From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.5 required=3.0 tests=BAYES_05,FREEMAIL_FROM, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:ac8:5b03:0:b0:3f9:aa64:7dbf with SMTP id m3-20020ac85b03000000b003f9aa647dbfmr33873qtw.4.1688244892262; Sat, 01 Jul 2023 13:54:52 -0700 (PDT) X-Received: by 2002:a25:4254:0:b0:c4f:f5f:9e7e with SMTP id p81-20020a254254000000b00c4f0f5f9e7emr3239yba.2.1688244891938; Sat, 01 Jul 2023 13:54:51 -0700 (PDT) Path: eternal-september.org!news.eternal-september.org!tncsrv06.tnetconsulting.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 1 Jul 2023 13:54:51 -0700 (PDT) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=98.59.238.112; posting-account=oHOvdQoAAACYgyEBjgPNvKFOGxg8pNns NNTP-Posting-Host: 98.59.238.112 References: <41a5cad2-b5ca-4996-b057-e1ae8b27f526n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Using "pure" (?) Ada, how to determine whether a file is a "text" file, not a binary? From: Kenneth Wolcott Injection-Date: Sat, 01 Jul 2023 20:54:52 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 2519 Xref: news.eternal-september.org comp.lang.ada:65395 List-Id: On Saturday, July 1, 2023 at 1:39:30=E2=80=AFPM UTC-7, Jeffrey R.Carter wro= te: > On 2023-07-01 19:15, Kenneth Wolcott wrote:=20 > >=20 > > 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, al= l files=20 > are sequences of bytes, and so may be considered sequences of Characters,= and so=20 > text files.=20 >=20 > If you can define what distinguishes text files from binary files, then i= t=20 > should be fairly easy to write Ada to distinguish them.=20 >=20 > For example, if a text file is one in which all the characters, except li= ne=20 > terminators, are graphic characters, then it should be clear how to deter= mine=20 > whether a file meets that definition of a text file. I think that is the definition that I'm going to pursue as the simplest an= d effective definition. > > 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=20 > you would use and how to use it depends on what's in the file and what yo= u need=20 > to do with it.=20 Ok, now that seems to be pretty obvious! I'll go and experiment further..= . Thank you! Ken