Skip to content

Commit 15af9a1

Browse files
authored
Merge pull request #17 from choco-technologies/copilot/fix-dmclk-configuration-issue
Fix is_file() to distinguish directories from files
2 parents 2bb1ce5 + 3c3006e commit 15af9a1

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/dmdevfs.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,21 @@ static int unconfigure_drivers(dmfsi_context_t ctx)
964964
*/
965965
static bool is_file(const char* path)
966966
{
967-
return Dmod_Access(path, DMOD_F_OK) == 0;
967+
// Check if path exists
968+
if (Dmod_Access(path, DMOD_F_OK) != 0)
969+
{
970+
return false;
971+
}
972+
973+
// Try to open as directory - if it succeeds, it's a directory, not a file
974+
void* dir_handle = Dmod_OpenDir(path);
975+
if (dir_handle != NULL)
976+
{
977+
Dmod_CloseDir(dir_handle);
978+
return false; // It's a directory
979+
}
980+
981+
return true; // It's a file
968982
}
969983

970984
/**

0 commit comments

Comments
 (0)