Author Topic: ISFILE is vile !  (Read 821 times)

Robert

  • Hero Member
  • *****
  • Posts: 1363
    • View Profile
ISFILE is vile !
« on: June 06, 2024, 07:02:02 PM »
Code: [Select]
PRINT "It is ", BOOL$(ISFOLDER("C:\Windows\System32")), " that the folder C:\Windows\System32 exists."
PRINT "It is ", BOOL$(ISFILE("C:\Windows\System32\cmd.exe")), " that the file C:\Windows\System32\cmd.exe exists."

Result:

Code: [Select]
It is True that the folder C:\Windows\System32 exists.
It is False that the file C:\Windows\System32\cmd.exe exists.

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2538
    • View Profile
Re: ISFILE is vile !
« Reply #1 on: June 06, 2024, 07:17:57 PM »
Thanks Robert.

This corrected runtime corrects the problem for me (Windows 11 Pro).


Code: [Select]

int isfile(LPCTSTR FName) {
    static HANDLE Local_FileHandle = NULL;
    static WIN32_FIND_DATA Local_FindData;
    if (Local_FileHandle != NULL && Local_FileHandle != INVALID_HANDLE_VALUE) {
        FindClose(Local_FileHandle);
        Local_FileHandle = NULL;
    }
    Local_FileHandle = FindFirstFile(FName, &Local_FindData);
    if (Local_FileHandle == INVALID_HANDLE_VALUE) {
        return FALSE; // File not found
    }
    FindClose(Local_FileHandle); // Close the handle since it's no longer needed

    if (!(Local_FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
        return TRUE; // It is a file
    }
    return FALSE; // It is a directory
}


Robert

  • Hero Member
  • *****
  • Posts: 1363
    • View Profile
Re: ISFILE is vile !
« Reply #2 on: June 06, 2024, 07:38:16 PM »
Thank you. The fix works for me too.

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2538
    • View Profile
Re: ISFILE is vile !
« Reply #3 on: June 06, 2024, 07:54:17 PM »
Thank you. The fix works for me too.

Glad to hear it. 

I added the following to Revisions.txt 

I will upload BCX 8.1.0 in a few minutes.

Robert Wishlaw : Reported bug with ISFILE() function.  MrBcx corrected/improved/re-tested
                 the ISFILE(), ISFOLDER(), ISREADONLY(), ISHIDDEN() functions.