Advertisement
Guest User

Untitled

a guest
Feb 19th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. bool directory_exists( const string &directory )
  2. {
  3. #if _WIN32
  4. wstring directoryW( convert_to_utf16(directory) );
  5. struct _stat64 status;
  6. if( _wstat64(directoryW.c_str(), &status) == 0 )
  7. #else // _WIN32
  8. struct stat status;
  9. if( stat(directory.c_str(), &status) == 0 )
  10. #endif //_WIN32
  11. {
  12. if ( status.st_mode & S_IFDIR )
  13. return true;
  14. }
  15. return false;
  16. }
  17. bool file_exists( const string &filename )
  18. {
  19. #if _WIN32
  20. wstring filenameW( convert_to_utf16(filename) );
  21. struct _stat64 status;
  22. if( _wstat64(filenameW.c_str(), &status) == 0 )
  23. #else // _WIN32
  24. struct stat status;
  25. if( stat(filename.c_str(), &status) == 0 )
  26. #endif //_WIN32
  27. {
  28. if ( status.st_mode & S_IFREG )
  29. return true;
  30. }
  31. return false;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement