Updated function to use full path instead of rootdir.