FileExists Function Request

Monkey Forums/Monkey Programming/FileExists Function Request

Shinkiro1(Posted 2012) [#1]
I think this is really needed.

FileExists (path:String) 


In glfw it's already possible via FileType().
In IOS i found this: http://stackoverflow.com/questions/1638834/how-to-check-if-a-file-exists-in-documents-folder
Android: http://stackoverflow.com/questions/2786655/test-if-file-exists
Html: http://www.codingforums.com/showpost.php?p=1155364&postcount=5

Of course it should be more efficient than loading the file with LoadString and then checking the String for "".

Has anybody done this already?


ziggy(Posted 2012) [#2]
On C# there is this function:
bool system.io.file.exists(filename)
I supose it works out of the box on XNA


Shinkiro1(Posted 2012) [#3]
So XNA shouldn't be a problem then :)

I tried to implement the html5 code from the above link (text in red) and it seemed to work except that it still took 2ms to check a file.

Out of curiosity I tried the same in BlitzMax.
Using FileType() I could check 10000 (same) files in 15ms.
So there has to be something wrong with the html code.


fsoft(Posted 2012) [#4]
Shinkiro1, the HTML code is slower because it spawns an XMLHTTPRequest each time it has to check for the file while the BlitzMax code actually checks using file system functions, and BTW: I suppose the underling operation system will cache your request at some point, making it lightspeed.


Aman(Posted 2012) [#5]
I have created an fstream module long time ago. It supports: Android, GLFW, XNA(tested on WP7, and windows), and maybe iPhone as it was long time ago. It is now a part of my GUI module. I will make it into a seperate module and post it here. It can read, write, and create files.


ziggy(Posted 2012) [#6]
It can read, write, and create files.
I'm very interested on this.


NoOdle(Posted 2012) [#7]
Me too, that would be very very useful! It would be great if iPhone is supported as well.


Aman(Posted 2012) [#8]
I created the module. There is no iOS support though. I guess I didn't have time to look up into it then. Here is the link:
http://monkeycoder.co.nz/Community/posts.php?topic=2679