[Gambas-user] Size of a directory

Sebastián Kulesz sebikul at gmail.com
Fri Sep 21 14:24:32 CEST 2018


Í already implemented that solution in a module here:
https://github.com/sebikul/mundus/blob/master/.src/PathHelper.module

You are free to use it if it suits your needs!

Regards

On Fri, Sep 21, 2018, 09:21 Me <adamnt42 at gmail.com> wrote:

> On Fri, 21 Sep 2018 11:52:30 +0200
> Rolf-Werner Eilert <rwe-sse at osnanet.de> wrote:
>
> > Am 21.09.2018 um 11:26 schrieb Benoît Minisini:
> > > Le 21/09/2018 à 10:54, Hans Lehmann a écrit :
> > >> Hello,
> > >>
> > >> how do I determine the size (ilDirSize As Long) of a directory using
> > >> Gambas?
> > >>
> > >> With kind regards
> > >>
> > >> Hans
> > >>
> > >> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net
> ]----
> > >>
> > >
> > > You can't, because on Unix there is no system call to get the size of
> a
> > > directory. And I never understood the reason why they didn't implement
> > > that.
> > >
> > > You have to browse the directory, and add the size of each file one by
> > > one. Very slow...
> > >
> >
> > The reason is, what do want to know: only the size of the directory
> > itself, or recursively all subdirectories too, and do you want files
> > from links being included or excluded, and if so, only softlinks or
> > hardlinks, and do you want a size in bytes or clusters...???
> >
> > A ready-made function by the filesystem would not do anything else than
> > a function you code for yourself in, say, C, and it could not be any
> > faster. And it would have to cope with all exceptions and special
> > wishes, so a decent one made for yourself would be almost faster anyway.
> >
> > As far as I heard, the most advanced file systems like Btrfs (though I
> > don't like it) offer such fancies. From Gambas this would mean to shell
> > out and call the commandline function for it. Whereas - when we speak of
> > Btrfs - the size left on the media is only a rough guess, so they
> > recommend to keep at least 20 % as a security buffer. You will know why
> > once you crossed the limit...
> >
> > But when you stay whithin one directory and leave out any linked files
> > and do not go recursive, then it can be rather fast. I know that from
> > midnight commander.
> >
> > Regards
> > Rolf
> >
> > ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
> du
>
> Don't know. Is that still around? Back in the good old days of limited
> disk space that was the goto
> to find out who/where the disk hogs were. Lots of command line options and
> you have to parse
> the output, But it beats the hell out of writing recursive ...
>
> du -shu ..nope ...
> du -sh * ... nope
> man du ...nope
> info du ? ...no i dont have info any more.
>
> ah to hell with it...
> https://www.google.com/search?q=linux+du+command&ie=utf-8&oe=utf-8&client=firefox-b-ab
>
> hth
> b
> --
> Me <adamnt42 at gmail.com>
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20180921/b886eeea/attachment.html>


More information about the User mailing list