Skip to content

Commit 9670969

Browse files
CopilotJohnAmadis
andcommitted
Fix is_file() to properly distinguish files from directories
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
1 parent 94df8ef commit 9670969

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 = Dmod_OpenDir(path);
975+
if (dir != NULL)
976+
{
977+
Dmod_CloseDir(dir);
978+
return false; // It's a directory
979+
}
980+
981+
return true; // It's a file
968982
}
969983

970984
/**

0 commit comments

Comments
 (0)