To find which file is loaded into a [bpatcher] you can use the js code included below. It will find any attribute of a named object if you send it the message "getattr ". For [bpatcher] the attribue is "name". I hope this helps.
A quick yet not-particularly-clever way of testing if its a [patcher] is to [sprintf %s.maxpat] the output to an [absolutepath] object. If its an abstraction or [bpatcher] it should show you the destination. However this is also true if you name your [patcher] the same as a file in your search path.
To test for abstraction vs. [bpatcher] you could try myobj.getattr() and then test for an attribute that only the [bpatcher] has, like "offset" or "clickthrough", I haven't tested this though so no promises it will work.
I'll look into this a bit closer when I finish work this evening.
I've just tried getattr("offset") and other things but it doesn't work at all, for unknown reasons (it should work, indeed). For example "offset" always returns 1 for everything, patchers, bpatchers... while "enablehscroll" always returns "null"...
That is odd. I've had trouble with getattr() before (see link below) but assumed it was me doing something wrong. What's weirder is that it finds "name" but not some of the other attributes. It's quite annoying that [patcher], [bpatcher] and abstractions return "patcher" as the maxclass but thats just the way it is I guess.
First I tried the obj.getattr("ignoreclick") which doesn't work (anyone know why?).
Next I tried obj.understands("ignoreclick") which works when the [bpatcher] is empty but not when there is a subpatch loaded into it, which sort of makes sense as the subpatch could understand that particular message.
Lastly I tested the height of the object and if it's greater than my regular object size of 20 then assume it is a [bpatcher], not great but does the job in most cases.
if ((obj.rect-obj.rect > 20) && (obj.maxclass == "patcher"))