comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: xor
Date: Sat, 31 Mar 2012 00:53:06 +0300
Date: 2012-03-31T00:53:06+03:00	[thread overview]
Message-ID: <9tmoa2Fu2tU1@mid.individual.net> (raw)
In-Reply-To: <jl2rvg$g65$1@munin.nbi.dk>

On 12-03-30 02:41 , Randy Brukardt wrote:
> "Niklas Holsti"<niklas.holsti@tidorum.invalid>  wrote in message
> news:9ti9k2FjcvU1@mid.individual.net...
>> On 12-03-29 02:25 , Randy Brukardt wrote:
>>> "Niklas Holsti"<niklas.holsti@tidorum.invalid>   wrote in message
>>> news:9tgqomFflrU1@mid.individual.net...
>>>> On 12-03-28 18:23 , Michael Moeller wrote:
>>> ...
>>>>> I don't want to push your helpfulness to far, but I still don't
>>>>> know whether there is any means to determine the size of a file
>>>>> from within Ada other than using a C subroutine calling fstat.
>>>>
>>>> Two ways:
>>>>
>>>> - Ada.Directories.Size, given the file name.
>>>> - Ada.Direct_IO.Size, given an open (Direct_IO) file.
>>>
>>> Actually, three ways:
>>
>> Ok, I showed two ways, but did not mean that there aren't other ways.
>>
>>> Ada.Stream_IO.Size, given an open (Stream_IO) file.
>>
>> If "positioning is not supported" for the stream file, the result of
>> Ada.Stream_IO.Size is implementation defined. Positioning is probably
>> supported for the kinds of files the OP uses now, but it is a bit of trap
>> for possible future uses of the program, for example if the program is
>> later used in a shell pipeline. A pipe probably does not support
>> positioning.
>
> I'm pretty sure that if "positioning is not supported" for a particular
> stream file, none of the other mechanisms will provide any useful answers,
> either. That's especially true as most Ada compilers use a common I/O system
> to implement all of these packages, so the effects will be similar on all of
> them.
>
> File for which "positioning is not supported" are likely to be things like
> sockets, pipes, and devices. Those won't have a meaningful size no matter
> how they're accessed.

I agree, but I think it is much more likely that Ada.Streams will 
encounter such a file, than is the case for Ada.Directories or 
Ada.Direct_IO. Also, I think that Ada.Direct_IO.Open should raise 
Use_Error for such files (but this does not seem to be required in the RM).

> In any case, your point is really just another argument for not depending
> upon the size at all; depending on the sort of file, it may not even be a
> meaningful concept. So depending on the size decreases the utility and
> reusability of your code.

Agreed.

> That said, the OP knows that and it surely is
> their decision how to write their code.

And now the OP has several ways to find the Size, including some 
warnings about when these ways may not work (and fstat would not work 
either).

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .



  reply	other threads:[~2012-03-30 21:53 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-25 14:28 xor Michael Moeller
2012-03-25 14:01 ` xor Niklas Holsti
2012-03-25 15:16   ` xor Michael Moeller
2012-03-25 19:05     ` xor Dmitry A. Kazakov
2012-03-27 20:31       ` xor Michael Moeller
2012-03-25 19:26     ` xor Niklas Holsti
2012-03-27 20:09       ` xor Michael Moeller
2012-03-27 19:44         ` xor Dmitry A. Kazakov
2012-03-27 21:16           ` xor Michael Moeller
2012-03-27 21:14             ` xor Simon Wright
2012-03-27 22:56               ` xor Michael Moeller
2012-03-27 22:03             ` xor Georg Bauhaus
2012-03-27 23:50               ` xor Michael Moeller
     [not found]                 ` <bbedne9wdofZyu_SnZ2dnUVZ_hydnZ2d@earthlink.com>
2012-03-28 12:18                   ` xor Michael Moeller
2012-03-28 12:48                     ` xor Georg Bauhaus
2012-03-28 15:23                       ` xor Michael Moeller
2012-03-28 15:58                         ` xor Niklas Holsti
2012-03-28 17:28                           ` xor Michael Moeller
2012-03-28 23:25                           ` xor Randy Brukardt
2012-03-29  5:17                             ` xor Niklas Holsti
2012-03-29 23:41                               ` xor Randy Brukardt
2012-03-30 21:53                                 ` Niklas Holsti [this message]
     [not found]                         ` <jtmdnfjWWsUYoO7SnZ2dnUVZ_gSdnZ2d@earthlink.com>
2012-03-28 17:44                           ` xor Michael Moeller
2012-03-28 14:07                     ` xor Dmitry A. Kazakov
2012-03-28 16:16                       ` xor Michael Moeller
2012-03-28 16:08                         ` xor Dmitry A. Kazakov
2012-03-28 17:36                           ` xor Michael Moeller
     [not found]                             ` <tdadna1MV6uj5O7SnZ2dnUVZ_jidnZ2d@earthlink.com>
2012-03-28 21:48                               ` xor Georg Bauhaus
2012-03-29  7:43                               ` xor Dmitry A. Kazakov
2012-03-29  7:49                               ` xor Simon Wright
2012-03-27 21:28           ` xor Georg Bauhaus
2012-03-27 19:50         ` xor Randy Brukardt
2012-03-27 21:44           ` xor Michael Moeller
2012-03-27 22:01             ` xor Georg Bauhaus
2012-03-27 20:13         ` xor Jeffrey Carter
replies disabled

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