/* parse the root config .ini file. it is located in * ~/.android/avd/<name>.ini or Windows equivalent */ static int _avdInfo_getRootIni( AvdInfo* i ) { char* iniPath = path_getRootIniPath( i->deviceName ); if (iniPath == NULL) { derror("unknown virtual device name: '%s'", i->deviceName); return -1; } D("Android virtual device file at: %s", iniPath); i->rootIni = iniFile_newFromFile(iniPath); AFREE(iniPath); if (i->rootIni == NULL) { derror("Corrupt virtual device config file!"); return -1; } return 0; }
static char* _getAvdContentPath(const char* avdName) { char temp[PATH_MAX], *p=temp, *end=p+sizeof(temp); IniFile* ini = NULL; char* iniPath = path_getRootIniPath(avdName); char* avdPath = NULL; if (iniPath != NULL) { ini = iniFile_newFromFile(iniPath); AFREE(iniPath); } if (ini == NULL) { APANIC("Could not open: %s\n", iniPath == NULL ? avdName : iniPath); } avdPath = iniFile_getString(ini, ROOT_ABS_PATH_KEY, NULL); if (!path_is_dir(avdPath)) { // If the absolute path doesn't match an actual directory, try // the relative path if present. const char* relPath = iniFile_getString(ini, ROOT_REL_PATH_KEY, NULL); if (relPath != NULL) { p = bufprint_config_path(temp, end); p = bufprint(p, end, PATH_SEP "%s", relPath); if (p < end && path_is_dir(temp)) { AFREE(avdPath); avdPath = ASTRDUP(temp); } } } iniFile_free(ini); return avdPath; }