avoid off-by-one error in path manipulation

Use library functions for path manipulation. This avoids
an occasional off-by-one error that caused code to be put
in a directory 'rc' instead of 'src'.

fixes #61