Opening file with spaces in it's name on cpp target


We’re trying to create a sales application that can dynamically display salesman’s powerpoint presentation files using the host default application.

I can get it to work on both html5 and cpp when the filename or path doesn’t have any spaces, but on cpp if the filename has a space it fails.

Ive tried using StringTools.quoteWinArg, but it adds a trailing backslash that I can’t seem to get rid of, and doesn’t show in the trace.

The file name for testing is defined as targetName = “user/presentation/SALES PRESENTATION.pptx”

I’ve also tried breaking it down and joining the elements, but the space always causes a problem.

On html5 this works no problem…


But not on CPP, so far I have

#if (cpp || neko || windows || mac)
	import sys.FileSystem;
	import hx.strings.Paths;
	import hx.strings.Strings;

var pathtoFile:String =[, targetName]);
var dirName:String = Paths.dirname(pathtoFile);
var stripName:String = Paths.basename(targetName);
var normPath1:String = Paths.normalize(dirName, WIN);
var normPath2:String = Path.join([normPath1, stripName]);
var normPath3:String = StringTools.quoteWinArg(normPath2, false);


Thanks for the report! I didn’t realize it was failing on spaces, but sure enough, start "path with spaces" just opened a command-prompt :frowning:

We could consider using explorer instead of start (not sure what the full consequences would be) but in the meantime, it appears that adding "" as the first argument to start fixes it, as the first argument can be a title, an argument with spaces comes through as a title instead of a path

Try this out, thanks :slight_smile:


Excellent, yes that works, I can go back to…


Much simpler :grinning: