Hello,
i have try to program a small tool to call whdl images with JST maped with foldername/diskimage.slave. For this I have try to get the current folder with an recursive scan. But this is not successfull, maybe i get here some hints to solve the issue.
void initializeTableData() {
BPTR dirLock;
totalRows = 0;
dirLock = Lock("", ACCESS_READ); // Jetzt Lock("") verwenden
if (!dirLock) {
printf("Fehler: Konnte aktuelles Verzeichnis nicht sperren. Fehlercode: %ld\n", IoErr()); [b]// --> Issue here, could not lock the folder.[/b]
return;
}
printf("Debug: Starte Verzeichnisdurchsuchung im aktuellen Verzeichnis.\n");
findSlaveFiles(dirLock, ""); // Leeren String für den Pfad übergeben
UnLock(dirLock);
printf("Debug: Verzeichnisdurchsuchung abgeschlossen. Gefundene Dateien: %d\n", totalRows);
}
void findSlaveFiles(BPTR dirLock, const char *path) {
struct FileInfoBlock *fib = (struct FileInfoBlock *)AllocMem(sizeof(struct FileInfoBlock), MEMF_CLEAR);
if (!fib) {
printf("Fehler: Speicher für FileInfoBlock konnte nicht zugewiesen werden.\n");
return;
}
BPTR subLock;
char fullPath[MAX_PATH];
while (Examine(dirLock, fib)) {
if (fib->fib_DirEntryType > 0) { // Unterverzeichnis
// Pfad zusammenbauen (mit korrekter Behandlung von Slashes)
snprintf(fullPath, MAX_PATH, "%s%s%s", path, (strlen(path) > 0 && path[strlen(path) - 1] != '/') ? "/" : "", fib->fib_FileName);
printf("Debug: Betrete Ordner: %s\n", fullPath);
printf("Debug: Versuche Verzeichnis zu sperren: '%s'\n", fullPath);
subLock = Lock(fullPath, ACCESS_READ);
if (!subLock) {
printf("Fehler: Konnte Ordner %s nicht sperren. Fehlercode: %ld\n", fullPath, IoErr());
}
if (subLock) {
findSlaveFiles(subLock, fullPath); // Rekursiver Aufruf!
UnLock(subLock);
} else {
printf("Fehler: Konnte Ordner %s nicht sperren. Fehlercode: %ld\n", fullPath, IoErr());
}
} else if (fib->fib_DirEntryType < 0 && strstr(fib->fib_FileName, ".slave")) { // Datei
snprintf(tableData[totalRows].slavePath, MAX_PATH, "%s%s%s", path, (strlen(path) > 0 && path[strlen(path) - 1] != '/') ? "/" : "", fib->fib_FileName);
snprintf(tableData[totalRows].displayName, MAX_PATH, "%s", fib->fib_FileName);
printf("Debug: Gefundene .slave-Datei: %s\n", tableData[totalRows].slavePath);
totalRows++;
if (totalRows >= MAX_ENTRIES) break;
}
}
FreeMem(fib, sizeof(struct FileInfoBlock)); //
}
./m68k-amigaos-gcc -o whdl6 /festplatte/Amiga/whdl6.cpp -I/opt/amiga/m68k-amigaos/ndk13-include -L/opt/amiga/m68k-amigaos/lib -lamiga -mcrt=nix13