2
0

DefaultIOSystem.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /** @file Default implementation of IOSystem using the standard C file functions */
  2. #include <stdlib.h>
  3. #include <string>
  4. #include "DefaultIOSystem.h"
  5. #include "DefaultIOStream.h"
  6. using namespace Assimp;
  7. // ------------------------------------------------------------------------------------------------
  8. // Constructor.
  9. DefaultIOSystem::DefaultIOSystem()
  10. {
  11. // nothing to do here
  12. }
  13. // ------------------------------------------------------------------------------------------------
  14. // Destructor.
  15. DefaultIOSystem::~DefaultIOSystem()
  16. {
  17. // nothing to do here
  18. }
  19. // ------------------------------------------------------------------------------------------------
  20. // Tests for the existence of a file at the given path.
  21. bool DefaultIOSystem::Exists( const std::string& pFile) const
  22. {
  23. FILE* file = fopen( pFile.c_str(), "rb");
  24. if( !file)
  25. return false;
  26. fclose( file);
  27. return true;
  28. }
  29. // ------------------------------------------------------------------------------------------------
  30. // Open a new file with a given path.
  31. IOStream* DefaultIOSystem::Open( const std::string& strFile, const std::string& strMode)
  32. {
  33. FILE* file = fopen( strFile.c_str(), strMode.c_str());
  34. if( NULL == file)
  35. return NULL;
  36. return new DefaultIOStream( file, strFile);
  37. }
  38. // ------------------------------------------------------------------------------------------------
  39. // Closes the given file and releases all resources associated with it.
  40. void DefaultIOSystem::Close( IOStream* pFile)
  41. {
  42. delete pFile;
  43. }
  44. // ------------------------------------------------------------------------------------------------
  45. // Returns the operation specific directory separator
  46. std::string DefaultIOSystem::getOsSeparator() const
  47. {
  48. #ifndef _WIN32
  49. std::string sep = "/";
  50. #else
  51. std::string sep = "\\";
  52. #endif
  53. return sep;
  54. }