101 char app_pkgname[128] = {};
102 const char *app_id = NULL;
103 int len_app_pkgname = 0;
104 int found = 0;
105
106 buffer[0] = '\0';
107
108 app_home = getenv("XDG_CONFIG_HOME");
109
111 app_id = getenv("APP_ID");
112
113 if (app_home == NULL || app_id == NULL)
114 {
115 return;
116 }
117
118 // Strip the '_' to get the APP_PKGNAME
119 strncpy(app_pkgname, app_id, sizeof (app_pkgname) - 1);
120 len_app_pkgname = strlen(app_pkgname);
121 for (int i = 0; i < len_app_pkgname; i++)
122 {
123 if (app_pkgname[i] == '_')
124 {
125 app_pkgname[i] = '\0';
126 found = 1;
127 break;
128 }
129 }
130
131 if (! found)
132 {
133 // Something goes Wrongs :/
134 ERROR_PRINTF("Error with APP_ID");
135 return;
136 }
137
138 // Build the path
139 snprintf(buffer, len - 1, "%s/%s/", app_home, app_pkgname);
140
141 // Create directory if needed
142 mkdir(buffer, 0755);