carl.sutton Posted March 19, 2012 Share Posted March 19, 2012 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
ulf.schroeter Posted March 19, 2012 Share Posted March 19, 2012 Try it with absolute/full path (e.g. prepend result from engine.getDataPath() ) Link to comment
carl.sutton Posted March 19, 2012 Author Share Posted March 19, 2012 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
ulf.schroeter Posted March 19, 2012 Share Posted March 19, 2012 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
carl.sutton Posted March 19, 2012 Author Share Posted March 19, 2012 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
carl.sutton Posted March 20, 2012 Author Share Posted March 20, 2012 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
unclebob Posted March 20, 2012 Share Posted March 20, 2012 Hey Carl, That seems strange. Could you provide code where crash appeared? Also try this sample in attachments. filesystem.zip Link to comment
carl.sutton Posted March 20, 2012 Author Share Posted March 20, 2012 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
manguste Posted March 20, 2012 Share Posted March 20, 2012 Added to docs that an absolute path is required. Link to comment
danni.coy Posted April 24, 2012 Share Posted April 24, 2012 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
manguste Posted April 30, 2012 Share Posted April 30, 2012 engine.filesystem.isFile() has been added. Link to comment
Recommended Posts