DOESFILEEXIST issue

Previous topic - Next topic

spacefractal

I think DOESFILEEXIST() should not return a 1 on a folder, but returning a 2?

I got some crashes on iOS due some confuctions due the command also returned 1 on folder, which is not a file......
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Slydog

#1
Or, only return positive matches on folders if the name ends with a slash, such as:
DOESFILEEXIST("C:\Games") - Returns 0
DOESFILEEXIST("C:\Games\") - Returns 1

This lets you test specifically for folders, and not have folders interfere with file only testing.

Of course if a file is named 'Games' it would return '1', but return '0' if ended by a slash, unless both a file and folder share the same name!

[Edit] Or have it NEVER return a positive match for a folder, and create a new command 'DOESFOLDEREXIST()'
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

MrTAToad

There is a DOESDIREXIST - DOESFILEEXIST is only for files...

spacefractal

#3
DOESFILEEXIST() should not return 1, but eiter 0 (its was not a file), or 2 (its was a folder, not a file).

By now its return 0 on Windows and 1 on iOS and might cause a crash (etc its does not crash on Windows, but does on iOS with same code). The game did crash on iOS when its tried to LOADSPRITE a folder because its thinked its was a file.

Howover I fixed the issue by checking if there is a "/" in the end or not, then its dont try to load that file. Howver its a strange little bug in that command (but easy to workaround).
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Hemlos

ios is being picky eh..

"./name/" shows directory name.

"name "alone suggests a file, because files do not need .ext's on them.
Extensions are only for a computer to know how to handle the files, through associations.
As a matter of fact, i make some data files without extentions myself.
These particular files i make, do not need to be opened or edited by any tools, therefore an association is not needed.

So this will be something, you as the programmer, will need to differentiate for the picky computer   :whip:
Bing ChatGpt is pretty smart :O

MrTAToad

Dont forget that iOS, like linux is treating everything as a file...

spacefractal

#6
Glbasic should been aware of it when that kind of named commands (etc skip / at the end example) or it's have not been documented correct.

I use that for check if a tip exits (in greedy mouse) or its should been skipped (due not all have been drawn). Etc if I did not add a file name, then it's tried on the main folder instead. I excepted it to return false and then skipped the image.

as the command say "file exist", so it's should return false for not been a file (same with dir exits command if tried on files of course).

The bug is howover really pity minor, so nothing big at all:-).
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Kitty Hello

very strange. Should be fixed in V11.
I'm returning from a bool function - how can that be "2"?
...

spacefractal

#8
BlitzMax return 1 for file and 2 for folder from the samme command. Here its have been separated to two commands, so its nothing problem return boolean. Glbasic should just been aware about it since DOESFILEEXIST could return 1 on a folder on some systems, which its should returned a 0. Howover easy workaround by checking a "/" in the end and eventuelly double check it with a DOESDIREXIST (which I do not use here).

Its none important bug, and its really very easy to fix around if you are aware of it. For now its could just been documented (if not fixed in v11).
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/