PDA

View Full Version : local file path



sky
19th January 2011, 09:31
Hi All,

In my application I need to write out some file paths for an independent application to read and process. And I want to do it in a cross platform way. Which is to say:

If "home/sk/sk.dat" is the path to sk.dat then I want to write out:


1. On Linux : "home/sk/sk.dat"

2. On win : "home\sk\sk.dat"

Is there any QT Util which can do this automatically ?

Thanks in advance,
sky

Lesiok
19th January 2011, 09:57
Look at QDir::toNativeSeparators

sky
19th January 2011, 12:30
Thank You Lesiok. I wonder how I missed it!

szisziszilvi
20th January 2011, 09:59
the first works for me on Win XP and Ubuntu-Linux also. Even for the non-Qt ifstream/ofstream file handling mode, I tried it for FILE* also, but that failed, but that was just for being curious. But since than I'm not counting disappearing backslashs any more... :) (Well, it might be still not as correct as this nativeSeparator version, but works.)