Ver Fonte

Added chdir and pwd.

Branimir Karadžić há 11 anos atrás
pai
commit
bf241993a4
1 ficheiros alterados com 24 adições e 0 exclusões
  1. 24 0
      include/bx/os.h

+ 24 - 0
include/bx/os.h

@@ -39,6 +39,12 @@
 #	endif // BX_PLATFORM_ANDROID
 #endif // BX_PLATFORM_
 
+#if BX_COMPILER_MSVC
+#	include <direct.h> // _getcwd
+#else
+#	include <unistd.h> // getcwd
+#endif // BX_COMPILER_MSVC
+
 namespace bx
 {
 	inline void sleep(uint32_t _ms)
@@ -134,6 +140,24 @@ namespace bx
 #endif // BX_PLATFORM_
 	}
 
+	inline int chdir(const char* _path)
+	{
+#if BX_COMPILER_MSVC
+		return ::_chdir(_path);
+#else
+		return ::chdir(_path);
+#endif // BX_COMPILER_
+	}
+
+	inline char* pwd(char* _buffer, uint32_t _size)
+	{
+#if BX_COMPILER_MSVC
+		return ::_getcwd(_buffer, (int)_size);
+#else
+		return ::getcwd(_buffer, _size);
+#endif // BX_COMPILER_
+	}
+
 } // namespace bx
 
 #endif // BX_OS_H_HEADER_GUARD