[Newbies] RE: Determining File Size

Van Upboy van.upboy at gmail.com
Sun Mar 21 08:22:46 UTC 2010


Subbu, thanks for the hint to look for the directoryEntry.

I have working code (see example).
When I inspect aFile then the other variables are there (for instance, there
is a creationTime which contains a number, and there is a fileSize).
But the fileSize = 0.

1. What is going wrong with the fileSize, because the file is much bigger
than 0!

2. How can I change creationTime to something readable? Now it is a
LargePositiveInteger, not very useful to display.

| aFileDir aFile |

    aFileDir := (FileDirectory default directoryNamed: 'mytestdir').
    aFile := aFileDir directoryEntryFor: 'my test file.mp3'.
    Transcript cr;show: aFile creationTime printString.
    Transcript cr;show: aFile fileSize printString.

Regards,
Van.

Hi,
>
> I'm listing files in a directory, but I want to show more than just the
> filename (like file size and may be creation date). I've searched for some
> time on the Internet, but I can't find the answer. How to do this?
>
> I've tried this:
>    aFile := (FileDirectory default directoryNamed: directoryName)
>            assureExistence;
>            readOnlyFileNamed: 'testfile.pdf'.
>    and then tried: aFile size but that doesn't seem to work.
>
> Regards,
> Van.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://lists.squeakfoundation.org/pipermail/beginners/attachments/20100320/c8e4ab01/attachment-0001.htm
>
> ------------------------------
>
> Message: 5
> Date: Sat, 20 Mar 2010 21:11:59 +0530
> From: "K. K. Subramaniam" <subbukk at gmail.com>
> Subject: Re: [Newbies] determining file size?
> To: beginners at lists.squeakfoundation.org
> Cc: Van Upboy <van.upboy at gmail.com>
> Message-ID: <201003202111.59879.subbukk at gmail.com>
> Content-Type: Text/Plain;  charset="iso-8859-15"
>
> On Saturday 20 March 2010 09:02:32 pm Van Upboy wrote:
> > I'm listing files in a directory, but I want to show more than just the
> > filename (like file size and may be creation date). I've searched for
> some
> > time on the Internet, but I can't find the answer. How to do this?
> File size is an attribute of the file's entry in its directory.
>
> See fileSize method in DirectoryEntry class. If you already have a file
> handle
> or a stream opened on it, use directoryEntry method. E.g.
>
>  stream directoryEntry fileSize
>
> HTH .. Subbu
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20100321/40ef4247/attachment.htm


More information about the Beginners mailing list