Add new common function for handling directory string value