Fixed directory size calculation routine

closedir() now is invoked only if DIR* was actually opened.
Also return early from calculation cycle if an error occurs.
Merge pull request #1 from andrey-malets/fix-calc-dir-size

Fixed directory size calculation routine