Jump to content

Recommended Posts

So I was doing some bug hunting within one of my plug ins, and I seem to be getting some unexpected results from the vs.FindFileInPluginFolder() function.

 

I'm using the function to retrieve the filepath for a file within my plug ins folder, which works absolutely fine. Where I'm running into problems is when I'm trying to handle a situation where said file does NOT exist...

 

 Below is the test code i'm using:

import vs

ok,path = vs.FindFileInPluginFolder('FileName.ini')

if ok:  # If File Exists
	vs.AlrtDialog("ok")
else:  # If File Does NOT Exist
	vs.AlrtDialog("no")

The problem I seem to be running into is that the ok Boolean keeps returning True even when the file is definitely not present within the Plug Ins folder.

 

First I thought it was still just cached in VW memory somewhere, so tried the old restarting VW trick. Same result.

 

Eventually I noticed that I had another File called "FileName.vso" in the plug ins folder. a bit of experimentation later yielded these results:

 

When FileName.ini is NOT present within Plug Ins Folder, but FileName.vso IS present:

 

FindFileInPluginFolder('FileName.ini') Returns True

FindFileInPluginFolder('RandomName.ini') Returns False

FindFileInPluginFolder('FileName.randomfileextension') Returns True

 

So from this it would suggest to me that FindFilePluginFolder command ignores file extensions and just looks for the File Name.

 

Is this working as intended? The Function reference does say it searches for File Name, but then the example further down has an extension attached to it, and I believe it's fairly common practice within most filename/path related programming functions to take the extension into account?

If this is working as intended does anyone have a nice workaround for dealing with same file names but different extensions. I was thinking I could probably do something with vs.GetFolderPath(-2) and some os.path commands...

 

I realize the simplest solution is just to make sure every file has a unique name, which is probably what i'll end up doing, but thought i'd see if anyone has any helpful insights before I go digging through all my code for every reference to this particular file...

 

Link to comment

Thanks Josh, When you say the Data Folder do you mean /Plug-ins/Data or /Plug-ins/Common/Data? 

 

Given that vs.GetFolderPath() has an attribute for Common/Data but not /Data I should probably use the Common folder?

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...