From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ccbf9deb2b62d073 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wn14feed!worldnet.att.net!bgtnsc04-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: File_size on windows Ada 2005 Reply-To: anon@anon.org (anon) References: <13g8me47tunfb77@corp.supernews.com> <13gbgls2c6q198b@corp.supernews.com> X-Newsreader: IBM NewsReader/2 2.0 Message-ID: Date: Fri, 05 Oct 2007 14:29:31 GMT NNTP-Posting-Host: 12.65.0.117 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1191594571 12.65.0.117 (Fri, 05 Oct 2007 14:29:31 GMT) NNTP-Posting-Date: Fri, 05 Oct 2007 14:29:31 GMT Organization: AT&T Worldnet Xref: g2news2.google.com comp.lang.ada:2318 Date: 2007-10-05T14:29:31+00:00 List-Id: 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" writes: >I am looking for the number of files in a directory. Any built-in functions >that will do this? >"anon" 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" >> 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 >>> >>> >>> >>>>>charset=3Diso-8859-1"> >>> >>> >>> >>> >>>
Does File_size work on directories? = >>>What does it=20 >>>return in windows?
>>> >>>------=_NextPart_000_0010_01C805F9.83195450-- >>> >> > >