ContentMgr findFile() from just file name
The challenge is to reference user-facing files when the user has moved them into a non-default directory structure. Consider the following example:
I am able to find the absolute dir for a file "\Props\DAZ Material Ball\Material Ball Scene.duf" which exists in a mapped content dir:
var foundFile = oContentMgr.findFile( "\\Props\\DAZ Material Ball\\Material Ball Scene.duf", DzContentMgr.AllDirsAndCloud );
I have been struggling with finding the absolute dir for the file "Material Ball Scene.duf" if the user has moved the user-facing file to a different mapped directory, for example "\Props\Testing\Material Ball Scene.duf". I've tried passing only the filename since the script would not know the different dir that the user moved the file to, but have so far been unsuccessful.
Is there any way to find the absolute dir of DUF file if the user has moved the file into a custom mapped dir?
If anyone has any solutions, or ideas, please let me know - thanks!
- Greg
Comments
findFile isn't a general search, it just sticks the relative path after each content directory path until it either finds its target or runs out of content directories to check. If you want to find a file that is in a non-standard location you are going to need to walk the directories yourself (and hope the one you find is the target and not a different file with the same name from a different product). I would use http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/dir_dz#a_1a4a1680ab91a5df2bf6e9993604c44f6b or one of its variants to write such a walker, but it would potentially be a very slow process.
Thank you very much for confirming that there are no existing functions to do so. Given your comments, maybe a better approach would be to give the user a chance to select a directory if a required user-facing DUF file is not dound in its default relative path.
In an effort to help future people who may have similar situations, check out doDirectoryDialog():
http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/filedialog_dz
Thanks again for taking the time to respond. I appreciate it.
- Greg