Jump to content

[SOLVED] is_file


photo

Recommended Posts

I can't get int is_file(string path) function to work which is leading me to believe I'm either missunderstanding its use or it is broken. For example if I wrote;

 

is_file("core/textures/mesh_base_diffuse.dds")

 

...it would return 0. But this is an existing file, and one which is visible to the filesystem so I am lost here. In fact I havn't been able to get the function to return anything but a 0. What is going on in this function and what is the alternative which I'm looking for? Thanks

Link to comment

I see. Well that solved one problem, even if it is a little inconsistant with other file system path strings that are relative to the data path. Thanks Ulf.

 

But my problem now is detecting existing ung archived files which is_file isn't picking up. Is there a different function that can do this? As the file system can read the directories of a ung as if they were transparent, I assumed this function would handle this.

Link to comment

is_file() is a wrapper for system level file functions (e.g. _wstat on Windows) and not implemented by Unigine FileSystem class.

 

In your case you could use engine.filesystem.getNumPackages()/getPackageFileName() for checking registered ung archives. Not very elegant, but at least it might do the job.

Link to comment

Thanks for your insight. I'll see what I can do with your suggestion. Perhaps the Unigine team can consider this in one of their future updates.

Link to comment

Both engine.filesystem.getNumPackageFiles() and engine.filesystem.getPackageFileName() will crash Unigine when I try to call them in a test project. Is there any sample code on how to use these functions?

Link to comment

How silly of me, I forgot my test scene will not be setting the password required to read my ung files! I didn't notice the error in my log files as it was at the very top. Thanks for the support.

Link to comment
  • 1 month later...

can we have a more elegant solution to this problem. Something along the lines of engine.filesystem.isFile() or alternatively making engine.filesystem.getFileName() return NULL if the filename fragment is not found.

Link to comment
×
×
  • Create New...