Once your language and support libraries are chosen, the next
portability issue is usually the location of key system files and
directories: mail spools, logfile directories and the like.
The archetype of this sort of problem is whether the mail spool
directory is /var/spool/mail or
/var/mail.
Often, you can avoid this sort of dependency by stepping back
and reframing the problem. Why are you opening a file in the mail
spool directory, anyway? If you're writing to it, wouldn't it be
better to simply invoke the local mail transport agent to do it for
you so the file-locking gets done right? If you're reading from it,
might it be better to query it through a POP3 or IMAP server?
The same sort of question applies elsewhere. If you find
yourself opening logfiles manually, shouldn't you be using
syslog(3)
instead? Function-call interfaces through the C library are better
standardized than system file locations. Use that fact!
If you must have system file locations in your code, your best
alternative depends on whether you will be distributing in source code
or binary form. If you are distributing in source, the
autoconf tools we discuss in the next
section will help you. If you're distributing in binary, then it's
good practice to have your program poke around at runtime and see if
it can automatically adapt itself to local conditions — say, by
actually checking for the existence of /var/mail and /var/spool/mail.
[an error occurred while processing this directive]