/* check if a filename is valid on the current platform. * FileNameValid checks if a fileName is valid on the current platform. * It test for DOS: the 8.3 convention if DOS_FS_8_3 is defined (not on Win32) * For all platforms: aux/con (portability issue) * returns 1 if fileName is valid, 0 if not. */ int FileNameValid( const char *fileName) /* fileName without spaces */ { #ifdef DOS_FS_8_3 const char *p = fileName; int l=0; int state=0; /* 0 is prefix, 1 is ext */ int maxAllow[2] = {8,3}; PRECOND(fileName != NULL); #endif if (StrCaseEq(fileName,"aux") || StrCaseEq(fileName,"con")) return 0; #ifdef DOS_FS #ifdef DOS_FS_8_3 while (*p != '\0') { if (l > maxAllow[state]) return 0; switch(*p) { case DIR_PATH_DELIM_CHAR: l = 0; /* new DOS_PREFIX */ break; case '.': l = 0; state++; if (state >= 2) return 0; break; default: l++; } p++; } return l <= maxAllow[state]; #else return 1; #endif #else # ifdef UNIX_FS PRECOND(fileName != NULL); return 1; # else # error no filesystem defined (UNIX_FS or DOS_FS) # endif #endif }
void Frustum::DeserializeFromXml(TiXmlElement *e) { type = StrCaseEq(e->Attribute("orthographic"), "true") ? OrthographicFrustum : PerspectiveFrustum; pos = float3::FromString(e->Attribute("pos")); front = float3::FromString(e->Attribute("front")); up = float3::FromString(e->Attribute("up")); e->QueryFloatAttribute("nearPlaneDistance", &nearPlaneDistance); e->QueryFloatAttribute("farPlaneDistance", &farPlaneDistance); e->QueryFloatAttribute("horizontalFov", &horizontalFov); e->QueryFloatAttribute("verticalFov", &verticalFov); }
/* compare filenames. * FileNamesEq compares two filenames obeying the naming * conventions of the current platform (case sensitive or not). * returns 1 if filenames are equal, 0 of not */ int FileNamesEq( const char *fileName1, /* first fileName without spaces */ const char *fileName2) /* second fileName without spaces */ { PRECOND(fileName1 != NULL); PRECOND(fileName2 != NULL); #ifdef DOS_FS return StrCaseEq(fileName1, fileName2); #else # ifdef UNIX_FS return StrEq(fileName1, fileName2); # else # error no filesystem defined (UNIX_FS or DOS_FS) # endif #endif }