Skip to content

Commit

Permalink
Merge pull request #153 from p2000t/150-retroforum-basic-demo-cassett…
Browse files Browse the repository at this point in the history
…e-files-keep-being-added

Replaced al_filename_exists by al_open_directory to check if dir exists
  • Loading branch information
dionoid committed Apr 20, 2024
2 parents 47ce6a3 + 0c97505 commit cb79087
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
"version": "2.0.0",
"tasks": [
{
"label": "Make",
"label": "Make Allegro",
"type": "shell",
"command": "make",
"command": "make allegro",
"group": "build",
"problemMatcher": []
},
{
"label": "Build and Run",
"label": "Build and Run Allegro",
"type": "shell",
"command": "./M2000",
"args": [
//"test/SAA5050.cas"
],
"dependsOn": [
"Make"
"Make Allegro"
],
"group": {
"kind": "build",
Expand Down
12 changes: 10 additions & 2 deletions src/allegro/Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ int CopyFile(ALLEGRO_PATH *sourceFolder, const char * filename, ALLEGRO_PATH *de
return ret;
}

bool al_directory_exists(const char * dir)
{
ALLEGRO_FS_ENTRY *fsDir = al_create_fs_entry(dir);
bool exists = al_open_directory(fsDir);
al_destroy_fs_entry(fsDir);
return exists;
}

void InitDocumentFolders()
{
int i;
Expand All @@ -197,11 +205,11 @@ void InitDocumentFolders()
CopyFile(resourcePath, "README.md", docPath);
al_set_path_filename(docPath, NULL);

if (!al_filename_exists(al_path_cstr(userCassettesPath, PATH_SEPARATOR)))
if (!al_directory_exists(al_path_cstr(userCassettesPath, PATH_SEPARATOR)))
for (i=0; installCassettes[i]; i++)
CopyFile(resourcePath, installCassettes[i], userCassettesPath);

if (!al_filename_exists(al_path_cstr(userCartridgesPath, PATH_SEPARATOR)))
if (!al_directory_exists(al_path_cstr(userCartridgesPath, PATH_SEPARATOR)))
for (i=0; installCartridges[i]; i++)
CopyFile(resourcePath, installCartridges[i], userCartridgesPath);

Expand Down

0 comments on commit cb79087

Please sign in to comment.