getFullPathName()

I am using the DocxFactory classes to build Docx documents. One of the things that are needed for this method to het it working is that I need to convert towards std::string instead of the regular Juce String.

I made a little piece of code for this:

 WordProcessingCompiler& l_compiler = WordProcessingCompiler::getInstance();
File myfilecompilen = File::getSpecialLocation(File::userDocumentsDirectory).getChildFile(filenaam);
String filecompilen = myfilecompilen.getFullPathName();
std::string stdfilecompilen = filecompilen.toStdString();

File myfileoutput = File::getSpecialLocation(File::userDocumentsDirectory).getChildFile(output);
String fileoutput = myfileoutput.getFullPathName();
std::string stdfileoutput = fileoutput.toStdString();

if (!myfileoutput.existsAsFile())

l_compiler.compile(stdfilecompilen, stdfileoutput);

When debugging this part, i see that I have a strange state of the my fileoutput for example:

I see the double \ in the filename and assume that this is creating the problem in the compiler of the DocxFactory. What am I doing wrong?

Windows 8.1
Latest version of Juce
VS2015

Kind regards, Harrie

That’s just how the compiler shows you the regular back-slashes. Back-slashes are normally used to “escape” characters that can otherwise not be used in a string. So in order for the compiler to know what you mean, you actually have to use two consecutive back-slashes to tell the compiler to generate one. The first back-slash basically says “the next character has to be put in the string literally”. The second back-slash then is the actual back-slash to be used.

You do the same when you type “\n\r”. This generates a new-line and a carriage-return. Only two characters, but you type four, using the back-slashes.

It’s displayed in the variables like that, so you can see the special control characters like the new-line and carriage-return.

1 Like