 
 
 
 
 
 
Re: How to store data files in packages
- To: mathgroup at smc.vnet.net
- Subject: [mg103677] Re: How to store data files in packages
- From: Vince <blueschi at gmail.com>
- Date: Fri, 2 Oct 2009 08:23:14 -0400 (EDT)
- References: <ha213g$n9i$1@smc.vnet.net>
On Oct 1, 6:42 am, "Karsten W." <karsten.g.wein... at googlemail.com>
wrote:
> Hello,
>
> my packages uses some data files. Currently, I store them in a
> subdirectory "resources" below the package directory and access the
> data via
>
> ToFileName[{$UserBaseDirectory, "Applications", myPackage,
> "resources"}, myDataFileName];
>
> I wonder if this is a portable way. I am afraid it is not, since the
> package may be installed under $BaseDirectory as well. And then there
> is this directory at the same level as "Applications" named
> "ApplicationData"
>
> What is the recommended way to store my data files?
>
> Any hint appreciated,
>
> kind regards,
> Karsten.
I think if you store the data in a relative subdirectory (say,
"Data"), and added the following to your package, you'd always be able
to find your data through "dataFiles".
dataFiles = FileNameJoin@{DirectoryName@FindFile@$Input, "Data"};
And I think this scales well. Consider multiple packages which all
reside in $UserBaseDirectory/Applications, and not a subdir thereof.
Those packages would share the "Data" directory. This could be
construed as a strength.
Vince Virgilio

