String bbRequestFile(String title,String filter,int save,String path) { String str; struct FilePathData *resolvePath = PathResolver(path, save); // If there was no error, the execute the dialog if (resolvePath->_err == 0) str = GTK_FileChooserDialog(title, filter, save, resolvePath); // Note that any GTK/GLIB functions that return a value allocated on the heap have to be freed with g_free and NOT free // or weird things could happen. g_free(resolvePath->_dirPath); g_free(resolvePath->_fileName); g_free(resolvePath->_fileExt); free(resolvePath); return str; }
std::string Environment::absolutePath(const std::string& name) const { std::string tmpName = Util::replace(name, PathResolver()); if ( tmpName.find("~/") == 0 ) tmpName = homeDir() + tmpName.substr(1); bool trailingSlash = !tmpName.empty() && tmpName[tmpName.size()-1] == '/'; char absolutePath[PATH_MAX]; if ( realpath(tmpName.c_str(), absolutePath) ) tmpName = absolutePath; if ( trailingSlash && !tmpName.empty() && tmpName[tmpName.size()-1] != '/' ) tmpName += '/'; return tmpName; }