[vtkusers] file handling
Sean McInerney
seanm at nmr.mgh.harvard.edu
Mon Mar 14 14:05:35 EST 2005
// methinks this'll work:
#include <stdlib.h>
#include <string.h>
char* dataRoot = getenv("VTK_DATA_ROOT");
const char* fileName = "/Data/masonry.bmp";
char* pathName = new char [strlen(dataRoot)+strlen(fileName)+1);
strcpy(pathName, dataRoot);
strcat(pathName, fileName);
// Voila!!! ... don't forget to call delete[] on pathName!!!
David Cole wrote:
>>
>> How would you write the line
>> reader SetFileName "$VTK_DATA_ROOT/Data/masonry.bmp"
>>
>> in C++?
>
>
> $VTK_DATA_ROOT represents the environment variable named VTK_DATA_ROOT.
> It should be replaced with the location of the VTKData folder on your
> system...
>
> A search of the current CVS VTK C++ source files for VTK_DATA_ROOT
> yields hits in the source file VTK/Rendering/vtkTesting.cxx. See that
> file for an example usage of getenv to extract the value of VTK_DATA_ROOT.
>
>
> Hope this helps,
> David
>
More information about the vtkusers
mailing list