comp.lang.ada
 help / color / mirror / Atom feed
From: anon@anon.org (anon)
Subject: Re: File_size on windows Ada 2005
Date: Fri, 05 Oct 2007 14:29:31 GMT
Date: 2007-10-05T14:29:31+00:00	[thread overview]
Message-ID: <fTrNi.639428$p47.71031@bgtnsc04-news.ops.worldnet.att.net> (raw)
In-Reply-To: 13gbgls2c6q198b@corp.supernews.com

Again the short answer is "No". 

Both answers are do to the File System and Operating System 
designers.  Most File System do not keep a running values of the 
number of files or the total byte size used in a directory.  Even 
the Command "Dir" must calculate its values.

So, you have to build an algorithm. 

PseudoCode like algorithm: 

  -- The following algorithm counts all sub-directories as files 
  -- with a size of 0.
  -- Also the directory entries "." and ".." are counted as 2 files
  -- with a file size of 0.

  Dir_Name := "dirname" ; -- dirname is the dir you want to process

                  -- Files that have hidden or system attributes may or 
                  -- may not be counted and in some systems you may 
                  -- need to use Dir_Name & "\*.*" or Dir_Name & "/*.*"
  Dir_File := Open ( Dir_Name ) ;  

                -- Total number of files
  File_Count := 0 ;
                 -- In some file system an empty dir may use some 
                 -- bytes like 10 for root.  So an offset nay be 
                 -- needed.
  Dir_Size   := 0 ;  

  while not end_of_file ( Dir_File ) loop
    Get ( Dir_File, File_Name ) ;
    File_Count := File_Count + 1 
    Dir_Size := Dir_Size + Size ( File_Name ) ;
  end loop ;
  Close ( Dir_File ) ;

                -- display the results

  Put ( "Directory: " ) ;
  Put ( Dir_Name ) ;
  Put ( " contains: " ) ;
  Put ( File_Count ) ;
  Put ( " files using  "  ) ;
  Put ( Dir_Size ) ;
  Put ( " bytes" ) ;
  New_Line ;


In <13gbgls2c6q198b@corp.supernews.com>, "ME" <abcdefg@nonodock.net> writes:
>I am looking for the number of files in a directory. Any built-in functions 
>that will do this?
>"anon" <anon@anon.org> wrote in message 
>news:aacNi.636279$p47.239974@bgtnsc04-news.ops.worldnet.att.net...
>> >
>>>Does File_size work on directories?
>>>What does it return in windows?
>>>
>>
>> The short answer is 'No'.  To obtain the directory size, an alogrithms
>> totals each file size, within a directory, then return this total amount.
>>
>>
>> In <13g8me47tunfb77@corp.supernews.com>, "ME" <abcdefg@nonodock.net> 
>> writes:
>>>This is a multi-part message in MIME format.
>>>
>>>------=_NextPart_000_0010_01C805F9.83195450
>>>Content-Type: text/plain;
>>> charset="iso-8859-1"
>>>Content-Transfer-Encoding: quoted-printable
>>>
>>>Does File_size work on directories? What does it return in windows?
>>>------=_NextPart_000_0010_01C805F9.83195450
>>>Content-Type: text/html;
>>> charset="iso-8859-1"
>>>Content-Transfer-Encoding: quoted-printable
>>>
>>><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>>><HTML><HEAD>
>>><META http-equiv=3DContent-Type content=3D"text/html; =
>>>charset=3Diso-8859-1">
>>><META content=3D"MSHTML 6.00.2900.3157" name=3DGENERATOR>
>>><STYLE></STYLE>
>>></HEAD>
>>><BODY bgColor=3D#ffffff>
>>><DIV><FONT face=3DArial size=3D2>Does File_size work on directories? =
>>>What does it=20
>>>return in windows?</FONT></DIV></BODY></HTML>
>>>
>>>------=_NextPart_000_0010_01C805F9.83195450--
>>>
>> 
>
>




      reply	other threads:[~2007-10-05 14:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <13g8me47tunfb77@corp.supernews.com>
2007-10-04 18:09 ` File_size on windows Ada 2005 Anh Vo
2007-10-05  1:06   ` Adam Beneschan
2007-10-05  1:33     ` Anh Vo
2007-10-04 20:37 ` anon
2007-10-05  4:51   ` ME
2007-10-05 14:29     ` anon [this message]
replies disabled

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