#include "cgfxShaderCommon.h"
#include "cgfxFindImage.h"
#include <maya/MStringArray.h>
#include <maya/MGlobal.h>
#include <maya/MFileObject.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef _WIN32
#else
# include <string.h>
#endif
static constexpr unsigned int kMaxPath = 1024;
{
struct stat statBuf;
char path[kMaxPath];
const char * psearchpath = searchpath.
asChar();
OutputDebugString("File = ");
OutputDebugString(name.
asChar());
OutputDebugString("\n");
#ifdef _WIN32
const bool fullyQualified = name.
index(
'/') == 0 || name.
index(
'\\') == 0 || name.
index(
':') == 1;
#else
const bool fullyQualified = name.
index(
'/') == 0 || name.
index(
'\\') == 0;
#endif
if (fullyQualified && stat(name.
asChar(), &statBuf) != -1) {
OutputDebugString("Returning fully qualified: ");
OutputDebugString(name.
asChar());
OutputDebugString("\n");
return name;
}
else {
else
resolvedName = name;
while (psearchpath < searchpath.
asChar() + searchpath.
length())
{
const char * endpath = strchr(psearchpath,';');
if (endpath)
{
strncpy(path,psearchpath, endpath - psearchpath);
path[endpath - psearchpath] = '\0';
}
else
{
strcpy(path,psearchpath);
}
psearchpath += strlen(path)+1;
bool fullPath = (path[0] == '/' ||
path[0] == '\\');
if (strlen(path) > 2)
{
fullPath = fullPath ||
(path[1] == ':' &&
(path[2] == '/' ||
path[2] == '\\'));
}
if(path[strlen(path) - 1] != '/')
file =
MString(path) +
"/" + resolvedName;
else
file =
MString(path) + resolvedName;
OutputDebugString("Try File = ");
OutputDebugString(file.
asChar());
OutputDebugString("\n");
if (stat(file.
asChar(), &statBuf) != -1) {
OutputDebugString("Returning: ");
OutputDebugString(file.
asChar());
OutputDebugString("\n");
return file;
}
}
OutputDebugString("Not found!\n");
}
}
{
{
workspace);
if ( status == MS::kSuccess)
{
texturePath += workspace;
texturePath += ";";
texturePath += workspace;
texturePath += "/textures;";
texturePath += workspace;
texturePath += "/images;";
texturePath += workspace;
texturePath += "/sourceimages";
}
char * cgfxPath = getenv("CGFX_TEXTURE_PATH");
if (cgfxPath)
{
if (texturePath.
length() > 0) {
texturePath += ";";
}
texturePath += cgfxPath;
}
else
{
char * cgfxRoot = getenv("CGFX_ROOT");
if (cgfxRoot)
{
if (texturePath.
length() > 0) {
texturePath += ";";
}
texturePath += cgfxRoot;
texturePath += "/textures/2D;";
texturePath += cgfxRoot;
texturePath += "/textures/cubemaps;";
texturePath += cgfxRoot;
texturePath += "/textures/3D;";
texturePath += cgfxRoot;
texturePath += "/textures/rectangles;";
texturePath += cgfxRoot;
texturePath += "/CgFX_Textures;";
texturePath += cgfxRoot;
texturePath += "/CgFX";
}
}
OutputDebugString("CgFX texture path is: ");
OutputDebugString(texturePath.
asChar());
OutputDebugString("\n");
fileName = cgfxFindFile(name, texturePath);
int hasFile = fileName.
length() > 0;
if (hasFile == 0)
{
if (idx == -1)
if (idx != -1)
{
fileName = cgfxFindFile(filename, texturePath);
hasFile = fileName.
length() > 0;
}
}
if( hasFile && projectRelative)
{
}
if (hasFile == 0)
OutputDebugString("Error: file not found.\n");
}
return fileName;
}
void
{
{
}
char * cgfxRoot = getenv("CGFX_ROOT");
if (cgfxRoot)
{
}
char * mayaLocation = getenv("MAYA_LOCATION");
if (mayaLocation)
{
option =
MString(
"-I") + mayaCgLocation;
}
}