File_Exists oddity

Product Compare Forums Multi-Edit Support File_Exists oddity

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2908
    Bret Sutton
    Participant

    Caveat: I’m running ME 2006.

    The File_Exists function, when passed a root directory name, returns inconsistent results.

    C: is an SSD. File_Exists("C:") returns a status of 0 (nonexistent).
    D: is an HDD. File_Exists("D:") returns a status of 2 (is a directory).
    M: is a SUBSTed drive – points to a directory on C:. File_Exists("M:") returns a status of 0 (nonexistent).
    S: is a SUBSTed drive – points to a directory on D:. File_Exists("S:") returns a status of 0 (nonexistent).

    For directories below root, File_Exists returns a status of 2 for all the drives.

    [code:34zdzzho]macro_file junk;
    #include StdDlgs.sh
    macro junk
    {
    str history_filename;
    int isfile;

    // All the following directories exist.
    history_filename = ‘c:’; Call Do_It;
    history_filename = ‘c:\Program Files’; Call Do_It;
    history_filename = ‘m:’; Call Do_It;
    history_filename = ‘m:\src’; Call Do_It;
    history_filename = ‘d:’; Call Do_It;
    history_filename = ‘d:\tmp’; Call Do_It;
    history_filename = ‘s:’; Call Do_It;
    history_filename = ‘s:\obsolete’; Call Do_It;
    Goto Exit;

    Do_It:
    isfile = File_Exists(history_filename);
    msgdlg(‘"’ + history_filename + ‘" status is ‘ + str(isfile),”,”,0);
    Ret;

    Exit:
    }[/code:34zdzzho]

    #9399
    tlscales
    Participant

    A simple workaround would be to add a "\" to any path that ends in ":" before doing the existence check.

    #9400
    Bret Sutton
    Participant

    Did you test that? I tried it for all those drives. None of them evaluated as directories. All returned a 0 value: c:\, d:\, m:\, and s:\. Here’s the test macro, if you want to give it a try. In general, File_Exists does not like trailing backslashes.
    [code:1d5tb25m] macro_file junk3
    #include StdDlgs.sh
    macro junk3
    {
    str some_filename;
    int isfile;

    // All the following directories exist.
    some_filename = ‘c:’; Call Do_It;
    some_filename = ‘c:\’; Call Do_It;
    some_filename = ‘c:\Program Files’; Call Do_It;
    some_filename = ‘m:’; Call Do_It;
    some_filename = ‘m:\’; Call Do_It;
    some_filename = ‘m:\src’; Call Do_It;
    some_filename = ‘d:’; Call Do_It;
    some_filename = ‘d:\’; Call Do_It;
    some_filename = ‘d:\tmp’; Call Do_It;
    some_filename = ‘s:’; Call Do_It;
    some_filename = ‘s:\’; Call Do_It;
    some_filename = ‘s:\obsolete’; Call Do_It;
    Goto Exit;

    Do_It:
    isfile = File_Exists(some_filename);
    msgdlg(‘"’ + some_filename + ‘" status is ‘ + str(isfile),”,”,0);
    Ret;

    Exit:
    }[/code:1d5tb25m]

    #9401
    Bret Sutton
    Participant

    Oops. You can’t really give it a try, can you, if you don’t have those drives and directories. Well, just make up some of your own. Trailing backslashes always precipitate return of a 0 (non-existent) value.

    #9402
    Clay Martin
    Keymaster

    Thanks for the info Bret. I posted this issue on the bug list, and linked back to this thread.
    Thanks,
    Clay

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.