Redmine#2178: add filestat function

Please review the semantics and functionality, and let me know if this has to be adjusted for Windows or other platforms.