We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The text was updated successfully, but these errors were encountered:
it's a mess
https://stackoverflow.com/questions/22694662/mac-os-x-can-i-write-application-files-within-the-app-bundle
https://stackoverflow.com/questions/5123361/finding-library-application-support-from-c
Sorry, something went wrong.
This code functions in a .app bundle which comes from apple... https://developer.apple.com/library/archive/qa/qa1549/_index.html
#include <glob.h> #include <string> #include <iostream> #include <fstream> #include <filesystem> char* CreatePathByExpandingTildePath(char* path) { glob_t globbuf; char **v; char *expandedPath = NULL, *result = NULL; if (path == NULL) { return "NULL"; } if (glob(path, GLOB_TILDE, NULL, &globbuf) == 0) //success { v = globbuf.gl_pathv; //list of matched pathnames expandedPath = v[0]; //number of matched pathnames, gl_pathc == 1 result = (char*)calloc(1, strlen(expandedPath) + 1); //the extra char is for the null-termination if(result) strncpy(result, expandedPath, strlen(expandedPath) + 1); //copy the null-termination as well globfree(&globbuf); } return result; } int main() { std::string home = CreatePathByExpandingTildePath("~/"); std::cout << home << std::endl; std::string support = home+"Library/Application Support/t"; if (!std::filesystem::exists(support)) { std::filesystem::create_directory(support); } std::ofstream out(support+"/data.json"); out << "{ \"some\": 1 }"; out.close(); }
Successfully merging a pull request may close this issue.
The text was updated successfully, but these errors were encountered: