OSX/BSD "defaults" program

Anyone know where I can find the source code for the Mac OS X /BSD defaults program?

Its man page is not specific about its behaviors, and I don't have access to a Mac.
By defaults program you mean the program that sets default actions for file types?
No, it is for preferences ... something like the windows registry (AFAICT).
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/defaults.1.html
Oh, derr, sorry xD. Why not just find an FTP site for the BSD source and save that particular build tree?
Alas, I was afraid I'd have to do something like that.

I think the command isn't actually in any BSD tree except for the OS X stuff...
Perhaps I'll have to fish around the NeXTStep sources...
Just out of curiosity, why do you need this?
I'm working on my text editor again... and I want to maintain cross-platform user preferences (such as: list of recently edited files - bookmarking information about said files, etc).

On Windows I will use the registry.

On *nix I will use the standard hidden RC file in the user's home directory.

On Mac, there are several options. One is the ~/Library/Preferences/appname... stuff.
Another is a platform-specific module that uses the native API for options/preferences (which I wish to avoid having to use).
Lastly (AFAIK) there is the "defaults" program, which I can pipe. Unfortunately, the man page is very sparse about what kind of output it will give (save for a couple of subcommands). In order to use the data, I need a more exacting specification.

(I am programming it using Tcl/Tk.)
Why not just use a flat text file? On Windows it can go in %PROGRAMFILES%\MyProgram\conf.txt, on UNIX it can be $HOME/.myprogram or /etc/myprogram.conf and on OSX it can be ~/Library/Preferences/myprogram or whatever OSX uses. That way, the only difference you need to make is which path to use and the data stays the same regardless.
"Sometimes the best solution is the most simple."
closed account (1yR4jE8b)
Windows also supports the concept of a home directory, with the %userprofile% environment variable which points to C:\Users\YourUsername, there is also the %appdata% folder which you can use which points to C:\Users\YourUsername\AppData\Roaming. The second option would be preferred because you wouldn't need to hide the files.

Hidden file in the home directory should work fine in all *nix's

Please stay far far away from the registry, it's an old dinosaur that needs to go extinct; the sooner the better.
"Sometimes the best solution is the most simple."


Absolutely agree.
Of course, those environment variables are filled from registry data.
closed account (1vRz3TCk)
Duoas,

defaults is a program that modifies the plist[1] for the program. The plist is just an XML file, so should be relatively easy to mod without the aid of the native APIs.


_____________________
[1] http://en.wikipedia.org/wiki/Property_list
@helios,
But the program doesn't need to know that, since Windows handles it. That way, Microsoft could get rid of the registry and as long as %foo% were still available it wouldn't matter (except to programs that use the registry directly).

I doubt MS will ever get rid of the registry, though; they love backwards compatibility. It's one of the few things Windows does really well (at least compared to other operating systems). You can still run some DOS programs on 32-bit Windows.
My point is that the registry isn't going anywhere any time soon.
I agree.
Yes, I am not interested in all the hate for the existing state of things. One thing that every operating system does differently is global and local application data.

On Windows, that's the registry, or a file in the APPDATA path. Tcl has registry access built-in, but obtaining the correct APPDATA path on Windows is problematic -- it would require the user to have his %APPDATA% environment variable properly set or a binary extension (like Ffidl or TWAPI).

On *nix it involves playing around with magic directories -- but at the simplest (local application data) it is just a hidden file or subdirectory in the user's home path.

On the Macintosh -- I know next to nothing beyond what I have written above.


Frankly, I don't think the registry is such a bad idea -- what people do with it is another thing....
A centralised database isn't a bad idea, but in practice it hasn't worked very well. The registry should only exist for Windows (i.e., the OS) to use, other programs should use INI files according to %APPDATA%.
I disagree... the problem is that there are relatively few controls put on the database, so everyone and his dog have the ability to poop all over it. There do exist several great tools to cull the registry of useless leftover junk.

A centralized database, as you said, isn't a bad idea. The way people use it is bad.
Topic archived. No new replies allowed.