Browse Source

Fix a bug in the previous commit

Panagiotis Christopoulos Charitos 5 years ago
parent
commit
33ae1cdff5

+ 0 - 2
samples/common/Framework.cpp

@@ -20,8 +20,6 @@ Error SampleApp::init(int argc, char** argv, CString sampleName)
 		return Error::USER_DATA;
 	}
 
-	printf("%s\n", StringAuto(alloc).sprintf("%s:%s", mainDataPath.cstr(), assetsDataPath.cstr()).cstr());
-
 	// Init the super class
 	ConfigSet config = DefaultConfigSet::get();
 	config.set("window_fullscreen", true);

+ 4 - 1
src/anki/resource/ConfigDefs.h

@@ -5,5 +5,8 @@
 
 ANKI_CONFIG_OPTION(rsrc_maxTextureSize, 1024u * 1024u, 4u, MAX_U32)
 ANKI_CONFIG_OPTION(rsrc_dumpShaderSources, 0, 0, 1)
-ANKI_CONFIG_OPTION(rsrc_dataPaths, ".", "The engine loads assets only in from these paths. Separate them with :")
+ANKI_CONFIG_OPTION(rsrc_dataPaths,
+	".",
+	"The engine loads assets only in from these paths. Separate them with : (it's smart enough to identify drive "
+	"letters in Windows)")
 ANKI_CONFIG_OPTION(rsrc_transferScratchMemorySize, 256_MB, 1_MB, 4_GB)

+ 25 - 0
src/anki/resource/ResourceFilesystem.cpp

@@ -210,6 +210,31 @@ Error ResourceFilesystem::init(const ConfigSet& config, const CString& cacheDir)
 	StringListAuto paths(m_alloc);
 	paths.splitString(config.getString("rsrc_dataPaths"), ':');
 
+	// Workaround the fact that : is used in drives in Windows
+#if ANKI_OS_WINDOWS
+	StringListAuto paths2(m_alloc);
+	StringListAuto::Iterator it = paths.getBegin();
+	while(it != paths.getEnd())
+	{
+		const String& s = *it;
+		StringListAuto::Iterator it2 = it + 1;
+		if(s.getLength() == 1 && (s[0] >= 'a' && s[0] <= 'z') || (s[0] >= 'A' && s[0] <= 'Z') && it2 != paths.getEnd())
+		{
+			paths2.pushBackSprintf("%s:%s", s.cstr(), it2->cstr());
+			++it;
+		}
+		else
+		{
+			paths2.pushBack(s);
+		}
+
+		++it;
+	}
+
+	paths.destroy();
+	paths = std::move(paths2);
+#endif
+
 	if(paths.getSize() < 1)
 	{
 		ANKI_RESOURCE_LOGE("Config option \"rsrc_dataPaths\" is empty");