# Function to access paclet resources?

Posted 4 days ago
202 Views
|
4 Replies
|
4 Total Likes
|
 Hello all,So I have a sizeable paclet built. In my PacletInfo.m, I have created a Resource that points to a file in the Resources directory of my paclet. The resource extension looks like this: Extensions -> { {"Resource", Resources->{{"FilePaths","Filepaths.txt"}} } } I've seen various places on-line that I should be able to use a function called PacletResource["PacletName","FilePaths"] to access and open that file. However, that function seems to be missing. Mathematica doesn't recognize it and I can't find anything like it in the help system.I have Mathematica 12.1 and the Paclet is installed in my user specific Paclets\Repository. I can use the Paclet and it works fine. I've tried loading "PacletManager'" and that function doesn't seem to be in there.What am I missing?Thanks
4 Replies
Sort By:
Posted 4 days ago
 You can use PacletManagerPacleResource["PacletName", "FilePaths"] or the newer form pObj["AssetLocation", "FilePaths"] where pObj is the appropriate PacletObject representing the paclet.
Posted 4 days ago
 @Ilian Gachevski Thanks for that.However, although the first form gives me no errors (that's better than I've been able to do on my own!), but it also gives no output. In[6]:= PacletManagerPacletResource["PackletName", "FilePaths"] (* No output here*) In[7]:= FileExistsQ[PacletManagerPacletResource["PacletName", "FilePaths"]] Out[7]= False The second option doesn't do any better. I can correctly create the PacletObject, and get its information, but getting "AssetLocation" just repeats the command, like it is an unknown command. In[7]:= PObj["AssetLocation", "FilePaths"] Out[7]= PObj["AssetLocation", "FilePaths"] Is this documented somewhere, or have I stepped into the outer limits? I can't find any documentation on PacletManager or it's functions.I did manage to get this to work: In[94]:= hString = Quiet@Import["PacletName\\Resources\\Filepaths.txt"] Out[94]= "Contents of Filespatths.txt" As long as hString != \$Failed I think this will work. Would be nice to know why that paclet resource isn't working, though.Thanks!
 To clarify, by pObj, I meant the result of pObj = PacletObject["PacletName"] or, equivalently pObj = First[PacletFind["PacletName"]].Getting Null for the PacletResource / AssetLocation means the asset does not exist in the paclet.A possible reason for that is that the default asset Root is ., but in your case the file is placed in a subdirectory called Resources`.