Get Application Directory on MacOS return path with appName.app/Contents/MacOS
I build cross-platform app that crate file for the user. To get full path I writing this code:
Code:
fullPath.append("/").append(filename);
After searching the file I found in the debugger that my file exist under <myAppName>.app/Contents/MacOS.
The user haven't way to get those file (except via the terminal).
The question: What should I do to receive "normal" path ? (I file aid to the user)
• I not want use substring functions because same code should work well on Linux and Windows.
Thanks in advance.
Re: Get Application Directory on MacOS return path with appName.app/Contents/MacOS
Quote:
Originally Posted by
AsfK
I build cross-platform app that crate file for the user. To get full path I writing this code:
Code:
fullPath.append("/").append(filename);
Well, that is the application's installation path. It is very likely that you can't create files in there (no permissions for normal users to create files in system locations).
Quote:
Originally Posted by
AsfK
The question: What should I do to receive "normal" path ? (I file aid to the user)
Are you looking for QStandardPaths?
Cheers,
_
Re: Get Application Directory on MacOS return path with appName.app/Contents/MacOS
Thank you Cheers
I didn't know about this (I came from Windows 'world'..)
I'll read about QSttandardPathes, thanks again!
btw, do you know If I can do If Def in my code (If the app. run on Mac save where I can, else in the executable folder...) or if can I ask permissions ?
Thanks,
AsfK
Re: Get Application Directory on MacOS return path with appName.app/Contents/MacOS
Quote:
Originally Posted by
AsfK
Thank you Cheers
I didn't know about this (I came from Windows 'world'..)
Even true on Windows :)
Well, on anything newer than Windows 98 and when not running with Administrator rights.
Quote:
Originally Posted by
AsfK
btw, do you know If I can do If Def in my code (If the app. run on Mac save where I can, else in the executable folder...)
You can do that, e.g. when building using Q_OS_MAC, Q_OS_WINDOWS, etc. but I wouldn't recommend it until you really have to. Makes it a lot harder to maintain.
Quote:
Originally Posted by
AsfK
or if can I ask permissions ?
Not sure what you mean by that?
Checking if you can write a file? QFileInfo::isWritable()
Ask the user for elevated rights? No cross-desktop way to do that and likely very unnecessary.
Cheers,
_
Re: Get Application Directory on MacOS return path with appName.app/Contents/MacOS