app bundle size

Is there a quick way to get the size of app bundle? Recursively scanning the bundle, even with MBS methods is too slow when you are going through a lot of bundles, i.e. the Applications folder.

Thanks,

Phil

Really? DirectorySizeMBS class is slow?

Well, I see it can be slow for apps like Xcode with thousands of files.
But running it in a timer with yielding can keep app responsive, especially if you run it in thread.

Reading the spotlight meta data of the bundle can help, sometimes it contains the total bundle size and sometimes it doesn’t.

There is another way; but I just can’t recall off the top of my head what it is. I’ve used it in the past.

You could probably use a shell to call out to the du command. Something like

du -sh <path to bundle>

[quote]Reading the spotlight meta data of the bundle can help, sometimes it contains the total bundle size and sometimes it doesn’t.

There is another way; but I just can’t recall off the top of my head what it is. I’ve used it in the past.[/quote]

Hmmm… I was wondering if there was a way via spotlight. Thanks.

[quote]You could probably use a shell to call out to the du command. Something like

du -sh [/quote]

I’ve tried variations of that and its still too slow. The Finder seems to get app sizes real quick and I’ve seen other file managers do it so there has got to be a way. Now whether or not that is feasible with Xojo is different story.

Since the size of the bundle should not change after build, it seems pretty easy to build once, get that value, and make it a constant.

That’s what I’m doing right now. I store the app sizes and modification dates in a DB. If the app is not in the DB or the dates don’t match up, then I calculate the app size otherwise I get it from the DB. So, the first time it opens the Applications folder its slow but much quicker after that.

Your OP did not mention the modification date.

Not sure I follow you there. I was just using the modification date to determine if the app size needed to be recalculated.

But anyway, problem solved. As per Sam R, spotlight contains the app bundle size. Easy enough to access with the MBS plugins.

Man, I’m going to have spring for that OmegaBundle now. :slight_smile:

http://documentation.xojo.com/index.php/SpotlightQuery

That works, too!. :slight_smile:

Norman,

I was unaware of this until following your link. But the I don’t see any such importer on my system. From the docs:

[quote]If it turns out that the importer does not work, it may be that there’s still an older importer present (e.g. the now-disfunctional REALbasic Spotlight importer released years ago). Removing this old importer should fix the issue.

To find any old importers, this is the best way to do it:

In Terminal, issue this command: “mdimport -L” This will list all Spotlight importers. One of them would be named “REALbasic.mdimporter”. It will include the path (older) in which this importer resides. Only if it resides inside the new IDE’s package, it’s the right one. If others are found, they should be trashed. Repeat these steps until “mdimport -L” lists the importer inside the IDE.

[/quote]

What should I do if mdimport -L does not list any importers for REALbasic or Xojo? I’m using 2016R4.1 at the moment.

The Spotlight importer is useful only for running spotlight queries against Xojo projects
And we’ve not shipped one in quite some time

But that doesn’t mean you cannot use the SpotlightQuery class to create & run spotlight queries from your app
We should clean that part of that reference page up

EDIT: Updated that page to not show references to an importer we don’t ship :slight_smile:

Ahh, OK. Just thought maybe something was wrong with my install.

Thanks

No
I think the last one we shipped was around 2013

Thomas Tempelmann was the original author and I have no idea if he’s kept it up to date or not

EDIT : This is about the most recent post I can find
https://forum.xojo.com/31518-spotlight-importer-updated-for-2016r1