applyed cherry-pick from master file system refactory
added directory handling part 1