Jump to content

[SOLVED] is_file


photo

Recommended Posts

Posted

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

Posted

Try it with absolute/full path (e.g. prepend result from engine.getDataPath() )

Posted

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.

Posted

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.

Posted

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.

Posted

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?

Posted

Hey Carl,

 

That seems strange. Could you provide code where crash appeared? Also try this sample in attachments.

filesystem.zip

Posted

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.

Posted

Added to docs that an absolute path is required.

  • 1 month later...
Posted

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.

×
×
  • Create New...