VEX: Check if a texture file exists? {[SOLVED]}

   724   2   0
User Avatar
Member
1177 posts
Joined: April 2017
Offline
Hi!

I have a path to a texture file. I know everything but it's extension (.tif, .exr, .png, etc.). I need to check each to verify if the texture exists. Is there a VEX function that can verify if the texture exists?

-Olivier
Edited by olivierth - April 16, 2025 09:41:08
User Avatar
Member
95 posts
Joined: Feb. 2020
Offline
I think you can use file_stat() [www.sidefx.com] in this case?

This docs provide this example of using it:


#include <file.h>

v@Cd = {1,0,0};
stat s = file_stat("$HH/pic/Mandril.pic");
if (s->isValid())
   v@Cd = {0,1,0};

In your case, I guess you would make an array of your possible file name endings and loop over it, checking if each version of the file exists. I don't suppose the function supports any "matching" syntax that would let you do a wildcard for the extension.
Edited by wyhinton1 - April 14, 2025 19:20:21
User Avatar
Member
1177 posts
Joined: April 2017
Offline
That sounds perfect!

Thanks, wyhinton1!
  • Quick Links