Branimir Karadžić 8 years ago
parent
commit
24e796fa5b
3 changed files with 29 additions and 11 deletions
  1. 7 2
      examples/common/entry/entry.cpp
  2. 15 2
      tools/shaderc/shaderc.cpp
  3. 7 7
      tools/texturev/texturev.cpp

+ 7 - 2
examples/common/entry/entry.cpp

@@ -5,7 +5,7 @@
 
 
 #include <bx/bx.h>
 #include <bx/bx.h>
 #include <bgfx/bgfx.h>
 #include <bgfx/bgfx.h>
-#include <bx/string.h>
+#include <bx/filepath.h>
 #include <bx/crtimpl.h>
 #include <bx/crtimpl.h>
 #include <bx/sort.h>
 #include <bx/sort.h>
 
 
@@ -585,7 +585,12 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 		inputAddBindings("bindings", s_bindings);
 		inputAddBindings("bindings", s_bindings);
 
 
 		entry::WindowHandle defaultWindow = { 0 };
 		entry::WindowHandle defaultWindow = { 0 };
-		entry::setWindowTitle(defaultWindow, bx::baseName(_argv[0]) );
+
+		bx::FilePath fp(_argv[0]);
+		char title[bx::kMaxFilePath];
+		bx::strCopy(title, BX_COUNTOF(title), fp.getBaseName() );
+
+		entry::setWindowTitle(defaultWindow, title);
 		setWindowSize(defaultWindow, ENTRY_DEFAULT_WIDTH, ENTRY_DEFAULT_HEIGHT);
 		setWindowSize(defaultWindow, ENTRY_DEFAULT_WIDTH, ENTRY_DEFAULT_HEIGHT);
 
 
 		sortApps();
 		sortApps();

+ 15 - 2
tools/shaderc/shaderc.cpp

@@ -5,6 +5,7 @@
 
 
 #include "shaderc.h"
 #include "shaderc.h"
 #include <bx/commandline.h>
 #include <bx/commandline.h>
+#include <bx/filepath.h>
 
 
 #define MAX_TAGS 256
 #define MAX_TAGS 256
 extern "C"
 extern "C"
@@ -704,6 +705,18 @@ namespace bgfx
 		strReplace(_data, find, "bgfx_VoidFrag");
 		strReplace(_data, find, "bgfx_VoidFrag");
 	}
 	}
 
 
+	const char* baseName(const char* _filePath)
+	{
+		bx::FilePath fp(_filePath);
+		char tmp[bx::kMaxFilePath];
+		bx::strCopy(tmp, BX_COUNTOF(tmp), fp.getFileName() );
+		const char* base = bx::strFind(_filePath, tmp);
+printf(" tmp: %s\n", tmp);
+printf("  fp: %s\n", _filePath);
+printf("base: %s\n", base);
+		return base;
+	}
+
 	// c - compute
 	// c - compute
 	// d - domain
 	// d - domain
 	// f - fragment
 	// f - fragment
@@ -888,7 +901,7 @@ namespace bgfx
 			bin2c = cmdLine.findOption("bin2c");
 			bin2c = cmdLine.findOption("bin2c");
 			if (NULL == bin2c)
 			if (NULL == bin2c)
 			{
 			{
-				bin2c = bx::baseName(outFilePath);
+				bin2c = baseName(outFilePath);
 				uint32_t len = (uint32_t)bx::strLen(bin2c);
 				uint32_t len = (uint32_t)bx::strLen(bin2c);
 				char* temp = (char*)alloca(len+1);
 				char* temp = (char*)alloca(len+1);
 				for (char *out = temp; *bin2c != '\0';)
 				for (char *out = temp; *bin2c != '\0';)
@@ -927,7 +940,7 @@ namespace bgfx
 
 
 		std::string dir;
 		std::string dir;
 		{
 		{
-			const char* base = bx::baseName(filePath);
+			const char* base = baseName(filePath);
 
 
 			if (base != filePath)
 			if (base != filePath)
 			{
 			{

+ 7 - 7
tools/texturev/texturev.cpp

@@ -7,7 +7,7 @@
 #include <bgfx/bgfx.h>
 #include <bgfx/bgfx.h>
 #include <bx/commandline.h>
 #include <bx/commandline.h>
 #include <bx/os.h>
 #include <bx/os.h>
-#include <bx/string.h>
+#include <bx/filepath.h>
 #include <bx/uint32_t.h>
 #include <bx/uint32_t.h>
 #include <bx/fpumath.h>
 #include <bx/fpumath.h>
 #include <bx/easing.h>
 #include <bx/easing.h>
@@ -490,7 +490,7 @@ struct View
 		return 0;
 		return 0;
 	}
 	}
 
 
-	void updateFileList(const char* _path, const char* _fileName = "")
+	void updateFileList(const char* _path, const bx::StringView& _fileName)
 	{
 	{
 		std::string path = _path;
 		std::string path = _path;
 
 
@@ -524,7 +524,7 @@ struct View
 
 
 						if (supported)
 						if (supported)
 						{
 						{
-							if (0 == bx::strCmp(_fileName, item->d_name) )
+							if (0 == bx::strCmp(item->d_name, _fileName) )
 							{
 							{
 								m_fileIndex = uint32_t(m_fileList.size() );
 								m_fileIndex = uint32_t(m_fileList.size() );
 							}
 							}
@@ -1072,13 +1072,13 @@ int _main_(int _argc, char** _argv)
 	std::string path = filePath;
 	std::string path = filePath;
 	if (!directory)
 	if (!directory)
 	{
 	{
-		const char* fileName = directory ? filePath : bx::baseName(filePath);
-		path.assign(filePath, fileName);
-		view.updateFileList(path.c_str(), fileName);
+		bx::FilePath fp(filePath);
+		path.assign(fp.getPath().getPtr(), fp.getPath().getTerm() );
+		view.updateFileList(path.c_str(), fp.getFileName() );
 	}
 	}
 	else
 	else
 	{
 	{
-		view.updateFileList(path.c_str() );
+		view.updateFileList(path.c_str(), "");
 	}
 	}
 
 
 	int exitcode = bx::kExitSuccess;
 	int exitcode = bx::kExitSuccess;