Is there a cross-platform way of determining 1) the app (the one that is being compiled) internal directory, 2) the app storage directory and 3) the app cache directory? I found the crate directories, but it requires the app name to retrieve the respective directories from (link).
Wouldn't something along the lines of
This will return something like the executable path, right? What I'm looking for is the path of the app internal and storage directory, not the path of where it was installed or ran. For example, on Android, if I recall correctly, the app directory is usually at
file://storage/emulated/0/Android/com.qux.foo, while on Windows it is usually located at
I mistyped at this part, so I fixed the original post.
It sounds like you are looking for the
Also keep in mind that different OSs will have different well-known folders. For example, the
dirs::runtime_dir() function will return
None for anything except Linux because
/run/user/ is a Linux-only concept.
Thanks, unfortunately these functions return user-based directory. I want to know the application directories, like it's possible in Adobe AIR above.
dirs::data_dir() in Windows returns
C:\Users\B\AppData\Roaming, but I want something like
Plainly, this is not a facility provided by every operating system. You will need to choose something to do with what's already there.
iOS and Android are the only platforms I'm aware of that actually provide the function you're asking for, and that's because they made it mandatory.
For data_dir, on all platforms you want to add another folder component after what it gives you with your application name.
In this case, is it possible to have a multi-thread static variable like follows in a library?
static mut APP_ID: &'static str = "";
So that I can change
APP_ID later to something like
"com.foo.app" through my app? I want this to avoid giving parameters to my library's structure.
Btw, this'd work, but it'd be good if
APP_ID was determined automatically.
#[link_name] const &'static str and see if it works?