Welcome, Guest. Please login or register.

Author Topic: development in Cpp for Kickstart 1.3  (Read 2216 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline chrisx78Topic starter

  • Newbie
  • *
  • Join Date: Dec 2024
  • Posts: 3
    • Show only replies by chrisx78
development in Cpp for Kickstart 1.3
« on: December 29, 2024, 07:17:01 PM »
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.

Code: [Select]
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


« Last Edit: December 29, 2024, 07:20:40 PM by chrisx78 »
 

Offline Thomas

Re: development in Cpp for Kickstart 1.3
« Reply #1 on: December 30, 2024, 02:03:50 AM »

Examine() returns information about the locked directory. In order to get a list of objects inside the directory you have to call ExNext() in a loop.

Offline chrisx78Topic starter

  • Newbie
  • *
  • Join Date: Dec 2024
  • Posts: 3
    • Show only replies by chrisx78
Re: development in Cpp for Kickstart 1.3
« Reply #2 on: December 30, 2024, 12:38:53 PM »
Thank you so much, thats the right hint.
But now i have the next secret, i want to start the application in the Workbench but the Screen is blue, and thats it..?

Code: [Select]
int wbmain(struct WBStartup *wbStartup) {
BPTR lock;

    // Prüfen, ob das Startverzeichnis übergeben wurde
    if (wbStartup && wbStartup->sm_ArgList && wbStartup->sm_ArgList->wa_Lock) {
        lock = DupLock(wbStartup->sm_ArgList->wa_Lock);
        if (!lock) {
            printf("Fehler: Konnte Startverzeichnis nicht duplizieren.\n");
            return 1;
        }
    } else {
        printf("Fehler: Kein gültiges Startverzeichnis erhalten.\n");
        return 1;
    }

    // Übergabe an die Hauptlogik
  char *argv[] = { const_cast<char*>("WorkbenchStart"), nullptr };

    int result = mainshell(1, argv);

    // Lock wieder freigeben
    UnLock(lock);

    return result;
}

int main(int argc, char **argv) {
    printf("Starte aus der Shell...\n");
    return mainshell(argc, argv);
}

// Prototypen
void initializeTableData();
void drawTable(struct Window *window);
void executeJST(const char *slavePath);
void findSlaveFiles(BPTR dirLock, const char *path);
int mainshell(int argc, char **argv); // Prototyp für mainshell


int mainshell(int argc, char **argv){
    struct Screen *screen;
    struct Window *window;
    struct IntuiMessage *msg;
    BOOL running = TRUE;
   BPTR lock = (BPTR)0;
    char currentDir[MAX_PATH] = "";

    if (argc > 0 && argv[0] != NULL) { // Shell-Start
        char *lastSlash = strrchr(argv[0], '/');
.
.
.

 

Offline Thomas

Re: development in Cpp for Kickstart 1.3
« Reply #3 on: December 30, 2024, 03:50:30 PM »

I am not sure what you mean by "the screen is blue". The screenshot looks like your program is running.

Offline chrisx78Topic starter

  • Newbie
  • *
  • Join Date: Dec 2024
  • Posts: 3
    • Show only replies by chrisx78
Re: development in Cpp for Kickstart 1.3
« Reply #4 on: December 30, 2024, 04:16:16 PM »
yes. only in the shell, the program is do the right stuff.
But if i klick on the Icon in the whdl load icon in the Workbench, everithing is blue like in the Backround. After some time the Amige hangs up and start new
I have attached the Program, you only need the remove the .txt
« Last Edit: December 30, 2024, 04:19:48 PM by chrisx78 »