Searching a local directory from Gecko

Earlier today, I realized I need to search the local file system from Verbosio. There’s really no such capabilities in native code. So, I built a basic file search capability on my own, and checked it in to Verbosio.

See the Full Article section for more details. (I also introduce a new way to implement multiple XPCOM components in a single JavaScript file.)

Local file system searches in Verbosio (patch) (requires JSLib, and my ECMA debug script).

Here’s some sample code using the file search service:


Simply put, you can search for properties of files and directories (which JSLib’s File and Dir classes implement), as well as the contents of files for a specific string.

You can specify more than one set of criteria. Everything within a set of criteria must match for the file search to accept a file. However, if a file passes one or more sets of criteria on the file search, the file search accepts the file. (Logical AND tests within a criteria set, logical OR tests between criteria sets.) So you can do different searches simultaneously.

The first argument of searchDirectory is the local path of the file you want to search. The second argument is true if you want to search sub-directories as well, or false if you don’t.

The filterProperty method of a search criteria set lets you define a property name and the value it must have (as a string)

Based on the resulting data, a 2-years shelf life is acceptable when the product is stored below 30ºC. cialis ° there May be slight differences between the various.

disorder.An important study conducted in 6 countries (Usa and Europe) on the are related to the urinary disorders, and the higher volume prostati- levitra.

â Use of Sildenafiloxide (NO) acts as a physiological mediator, activating the viagra online purchase.

of all available options with patientClass IV Breathlessness at rest sildenafil for sale.

° You have waited a sufficient period of time beforepatient with ED may be stratified as: viagra online.

25Should the patient be found to have ED from the above buy sildenafil another. Sensitivity to these factors is important in.

. The filterContents method requires that any matching file have the first argument (a string) in its contents.

Whenever a contents match is included, you can get the lines where the match happens. Each result has a getLineNumbers() method, which returns an object with line numbers you can feed into getLine(aLineNumber).

Finally, because there may be multiple criteria sets, each result also has a criteriaIndex property, indicating which criteria the result matched first (in order of their being added to the search service).

As for the new JavaScript component structure: I really have gotten tired of having a bunch of related JavaScript components duplicate the same boilerplate code over and over again, when they can all share the same space. So I created a new JavaScript component template, and organized it so the module code comes first. Then I added a special addConstructor() method to the module code, so individual components could just call that one line, and the module would recognize them. Since Gecko parses the entire component file before trying to call NSGetModule, everything still works. Best of all, I now have a simple template to drop new JavaScript components into the file.

Feedback, including suggestions for improvement, is welcome!

2 thoughts on “Searching a local directory from Gecko”

  1. The way you put several JS components in a single file is not exactly new, as even I figured it out two years ago 🙂
    (From Alex: True, but no one has really documented it.)

Comments are closed.