* Re: File_size on windows Ada 2005 [not found] <13g8me47tunfb77@corp.supernews.com> @ 2007-10-04 18:09 ` Anh Vo 2007-10-05 1:06 ` Adam Beneschan 2007-10-04 20:37 ` anon 1 sibling, 1 reply; 6+ messages in thread From: Anh Vo @ 2007-10-04 18:09 UTC (permalink / raw) On Oct 3, 8:10 pm, "ME" <abcd...@nonodock.net> wrote: > Does File_size work on directories? What does it return in windows? Use the function Directories.Size (String) return Directories.File_Size as shown in function specification below function Size (Name : String) return File_Size; AV ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: File_size on windows Ada 2005 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 0 siblings, 1 reply; 6+ messages in thread From: Adam Beneschan @ 2007-10-05 1:06 UTC (permalink / raw) On Oct 4, 11:09 am, Anh Vo <anhvofrc...@gmail.com> wrote: > On Oct 3, 8:10 pm, "ME" <abcd...@nonodock.net> wrote: > > > Does File_size work on directories? What does it return in windows? > > Use the function Directories.Size (String) return > Directories.File_Size as shown in function specification below > > function Size (Name : String) return File_Size; This doesn't necessarily work on directories, though, even though it's in the Directories package. The description of the Size function is: # Returns the size of the external file represented by Name. The size of an # external file is the number of stream elements contained in the file. If the # external file is not an ordinary file, the result is implementation- defined. and a directory is certainly not an ordinary file. So if you give it a directory name as the Name, it could raise an exception (possibly Name_Error, but not necessarily), or it could return a result that means something implementation-defined, or it could return meaningless garbage. -- Adam ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: File_size on windows Ada 2005 2007-10-05 1:06 ` Adam Beneschan @ 2007-10-05 1:33 ` Anh Vo 0 siblings, 0 replies; 6+ messages in thread From: Anh Vo @ 2007-10-05 1:33 UTC (permalink / raw) On Oct 4, 6:06 pm, Adam Beneschan <a...@irvine.com> wrote: > On Oct 4, 11:09 am, Anh Vo <anhvofrc...@gmail.com> wrote: > > > On Oct 3, 8:10 pm, "ME" <abcd...@nonodock.net> wrote: > > > > Does File_size work on directories? What does it return in windows? > > > Use the function Directories.Size (String) return > > Directories.File_Size as shown in function specification below > > > function Size (Name : String) return File_Size; > > This doesn't necessarily work on directories, though, even though it's > in the Directories package. The description of the Size function is: > > # Returns the size of the external file represented by Name. The size > of an > # external file is the number of stream elements contained in the > file. If the > # external file is not an ordinary file, the result is implementation- > defined. > > and a directory is certainly not an ordinary file. So if you give it > a directory name as the Name, it could raise an exception (possibly > Name_Error, but not necessarily), or it could return a result that > means something implementation-defined, or it could return meaningless > garbage. Oops! you are right. It raised Name_Error when I tested it. It would be nice if it returns some number such as 512 when issuing command line ls -l on Linux. AV ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: File_size on windows Ada 2005 [not found] <13g8me47tunfb77@corp.supernews.com> 2007-10-04 18:09 ` File_size on windows Ada 2005 Anh Vo @ 2007-10-04 20:37 ` anon 2007-10-05 4:51 ` ME 1 sibling, 1 reply; 6+ messages in thread From: anon @ 2007-10-04 20:37 UTC (permalink / raw) > >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-- > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: File_size on windows Ada 2005 2007-10-04 20:37 ` anon @ 2007-10-05 4:51 ` ME 2007-10-05 14:29 ` anon 0 siblings, 1 reply; 6+ messages in thread From: ME @ 2007-10-05 4:51 UTC (permalink / raw) 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-- >> > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: File_size on windows Ada 2005 2007-10-05 4:51 ` ME @ 2007-10-05 14:29 ` anon 0 siblings, 0 replies; 6+ messages in thread From: anon @ 2007-10-05 14:29 UTC (permalink / raw) 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-- >>> >> > > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-10-05 14:29 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [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 is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox