get canonical path?
-
Hi,
Are you thinking about QDir::canonicalPath ?
What local directory do you have in mind ? What for ?
For cross-platform path handling, take a look at QStandardPaths.
-
@kgregory said in get canonical path?:
Is there a QT library/object/method to obtain the canonical path to the local directory?
you mean QDir::canonicalPath()?
What local directory do you mean?Also, are there any tips for expressing file paths that will be understood on both Android and iOS?
Understood just by your app? If so you could use something like
%HOME%/path/to/somewhere
and replace the%HOME%
with the a Qt standard path
You will have to check if the standard locations return meaningful paths on both systems for you.Edit: @SGaist
lol, exactly the same thoughts ^^ -
I have a file that I plan to distribute with my app. I want to open the file with an API that I've obtained and the API says it requires the full canonical path. Therefore, I need the app to be able to find the full canonical path to the directory where my file is installed.
QDir::canonicalPath() will be useful, but I think I first need to know the path to the installation directory.
-
Where do you expect to store that file ?
-
If you intend to modify that file, use QStandardPath to retrieve a writable location. Neither iOS nor Android allow modification in the application folders.
-
That's odd. I've had a file that the app creates to store app data and have had no problem reading & writing it. I've supplied only a relative path in that case, though.
In this case, the API I'm integrating requries the full canonical path. Also, in this case, the file is read only.
-
You can't compare developing on your machine and running your application on a mobile device. Your technique will work on your machine because you are launching your application from a folder you have the rights to read from and write to. That won't be the case on your phone, tablet, etc.
-
You can read files within your application bundle, no problem with that. What you can't do is write them there.
-
I'm not sure where it's writing the file (I didn't provide any path). It is persistent and my app always finds it, so it's accomplished what I set out for it to do.
Perhaps it won't work when I try running this on iOS, in which case I'll have to give it more thought.