153
154
for (unsigned iCompCurr = 0; iCompCurr < pAcpiCpuPathLvl->cComponents; iCompCurr++)
155
156
PCSYSFSCPUPATHCOMP pPathComponent = &pAcpiCpuPathLvl->aComponentsPossible[iCompCurr];
158
/* Open the directory */
156
159
PRTDIR pDirCurr = NULL;
157
char *pszPathTmp = NULL;
160
rc = RTStrAPrintf(&pszPathTmp, "%s/%s*", pszPath, pPathComponent->pcszName);
164
/* Open the directory */
165
rc = RTDirOpenFiltered(&pDirCurr, pszPathTmp, RTDIRFILTER_WINNT);
160
char *pszPathTmp = RTPathJoinA(pszPath, pPathComponent->pcszName);
163
rc = RTDirOpenFiltered(&pDirCurr, pszPathTmp, RTDIRFILTER_WINNT);
168
164
RTStrFree(pszPathTmp);
167
rc = VERR_NO_STR_MEMORY;
172
171
/* Search if the current directory contains one of the possible parts. */
172
size_t cchName = strlen(pPathComponent->pcszName);
173
173
RTDIRENTRY DirFolderContent;
174
175
while (RT_SUCCESS(RTDirRead(pDirCurr, &DirFolderContent, NULL))) /* Assumption that szName has always enough space */
176
if (!strncmp(DirFolderContent.szName, pPathComponent->pcszName, strlen(pPathComponent->pcszName)))
177
if ( DirFolderContent.cbName >= cchName
178
&& !strncmp(DirFolderContent.szName, pPathComponent->pcszName, cchName))
178
char *pszPathLvl = NULL;
180
180
/* Found, use the complete name to dig deeper. */
182
182
pAcpiCpuPathLvl->uId = iCompCurr;
183
rc = RTStrAPrintf(&pszPathLvl, "%s/%s", pszPath, DirFolderContent.szName);
183
char *pszPathLvl = RTPathJoinA(pszPath, DirFolderContent.szName);
187
186
RTStrFree(pszPath);
188
187
pszPath = pszPathLvl;
190
rc = VERR_NO_STR_MEMORY;
235
236
/* Init everything. */
236
237
Assert(pAcpiCpuPathLvl->uId != ACPI_CPU_PATH_NOT_PROBED);
237
rc = RTStrAPrintf(&pszPath,
238
"%s/%s*", SYSFS_ACPI_CPU_PATH,
239
pAcpiCpuPathLvl->aComponentsPossible[pAcpiCpuPathLvl->uId].pcszName);
238
pszPath = RTPathJoinA(SYSFS_ACPI_CPU_PATH, pAcpiCpuPathLvl->aComponentsPossible[pAcpiCpuPathLvl->uId].pcszName);
240
return VERR_NO_STR_MEMORY;
243
242
pAcpiCpuPathLvl->pszPath = RTStrDup(SYSFS_ACPI_CPU_PATH);
244
243
if (!pAcpiCpuPathLvl->pszPath)
245
return VERR_NO_MEMORY;
246
return VERR_NO_STR_MEMORY;
247
249
/* Open the directory */
248
250
rc = RTDirOpenFiltered(&pAcpiCpuPathLvl->pDir, pszPath, RTDIRFILTER_WINNT);
258
260
rc = RTDirRead(pAcpiCpuPathLvl->pDir, &DirFolderContent, NULL);
259
261
if (RT_SUCCESS(rc))
263
263
/* Create the new path. */
264
rc = RTStrAPrintf(&pszPathCurr, "%s/%s", pAcpiCpuPathLvl->pszPath, DirFolderContent.szName);
264
char *pszPathCurr = RTPathJoinA(pAcpiCpuPathLvl->pszPath, DirFolderContent.szName);
267
rc = VERR_NO_STR_MEMORY;
268
271
/* If this is the last level check for the given core and package id. */
269
272
if (iLvlCurr == RT_ELEMENTS(g_aAcpiCpuPath) - 1)
306
309
Assert(pAcpiCpuPathLvl->uId != ACPI_CPU_PATH_NOT_PROBED);
308
rc = RTStrAPrintf(&pszPathDir, "%s/%s*", pszPathCurr, pPathComponent->pcszName);
311
pszPathDir = RTPathJoinA(pszPathCurr, pPathComponent->pcszName);
314
rc = VERR_NO_STR_MEMORY;
312
318
VBoxServiceVerbose(3, "New path %s\n", pszPathDir);