Saturday, September 27, 2008

debut org.icongarden.workingDirectory

I haven't had much time to work on Counterpart lately, but I did get a few hours this afternoon to throw at it, and I've checked in the beginning of the org.icongarden.workingDirectory extension. For now, it has two methods:
  • get returns a string containing a native path to the current working directory.
  • enumerate returns an array containing the names of the directory entries contained by the current working directory. In the near feature, this array will contain objects instead of strings, and each object will describe various other aspects of the corresponding directory entry, such as its type and its modification date.
Both these methods trust the environment variable PWD if it's present, which is normally the case because Counterpart sets it just before calling user scripts. However, if it's not set, these methods will figure out what it ought to be and set it before returning so they will run faster in the future. Once I finish enumerate, I plan to add two more methods.
  • descend changes the working directory to the child of the current working directory specified in its single parameter.
  • ascend changes the working directory to the parent of the current working directory.
This should be enough for the kinds of server-side scripts I have written in the past. The super-simple API is designed to insulate the client programmer from having to know too much about how file systems on specific platforms are organized.

These methods are implemented in C++. I may eventually build a script-based front end to them which knows how to explore file systems and/or represent paths (without separator characters, of course).

No comments: