Modernized folder permission check code