bool VDirAdapter::remove(const VString &strFileName) { if (strFileName.empty() || strFileName == "") return false; return (remove(strFileName.c_str()) == 0); }
bool VDirAdapter::removeDir(const VString &strDir) { if (strDir.empty() || strDir == "") return false; return (rmdir(strDir.c_str()) == 0); }
bool VDirAdapter_Unix::makeDir(const VString &strDir) { if (strDir.empty() || strDir == "") return false; return (mkdir(strDir.c_str(), S_IRWXU) == 0); }
uint32_t VDirAdapter_Unix::getLength() const { VString strPath = m_strRoot + VString(m_pDirent->d_name); struct stat s; int result = stat(strPath.c_str(), &s); return (result == 0 ? s.st_size : 0); }
bool VDirAdapter::findFile(const VString &strPath) { if (strPath.empty() || strPath == "") return false; #ifdef UNICODE WCHAR wszPath[512] = {0}; ::MultiByteToWideChar(CP_UTF8, 0, strPath.c_str(), strPath.length(), wszPath, sizeof(wszPath)); m_hFindFile = ::FindFirstFile(wszPath, &m_FindFileData); #else m_hFindFile = ::FindFirstFile(strPath.c_str(), &m_FindFileData); #endif extractRoot(strPath, m_strRoot); m_bExtractName = false; return (m_hFindFile != INVALID_HANDLE_VALUE); }
bool VDirAdapter_Unix::isDirectory() const { if (NULL == m_pDir || NULL == m_pDirent) return false; VString strPath = m_strRoot + VString(m_pDirent->d_name); struct stat s; int result = stat(strPath.c_str(), &s); return (result == 0 && S_ISDIR(s.st_mode)); }
bool VShadingPass::Compile(const VFileList &vertexShaders, const VFileList &fragmShaders) { VString bigSourceStr; for( VFileList::const_iterator i = vertexShaders.begin(); i != vertexShaders.end(); ++i ) { const VString &fileName = *i; CPVRTResourceFile shaderFile(fileName.c_str()); if( !shaderFile.IsOpen() ) return false; VString fileContent((const char*) shaderFile.DataPtr(), shaderFile.Size()); bigSourceStr += fileContent; } if( !mVertexShader.Create(GL_VERTEX_SHADER, bigSourceStr.c_str(), &mErrorLog ) ) { return false; } bigSourceStr.clear(); for( VFileList::const_iterator i = fragmShaders.begin(); i != fragmShaders.end(); ++i ) { const VString &fileName = *i; CPVRTResourceFile shaderFile(fileName.c_str()); if( !shaderFile.IsOpen() ) return false; VString fileContent((const char*) shaderFile.DataPtr(), shaderFile.Size()); bigSourceStr += fileContent; } if( !mFragmentShader.Create(GL_FRAGMENT_SHADER, bigSourceStr.c_str(), &mErrorLog ) ) { return false; } return true; }
bool VShader::Create(GLuint type, const VString &data, VString *logMessage) { mHandle = glCreateShader(type); if( glGetError() != GL_NO_ERROR ) return false; const GLchar *src[] = { data.c_str() }; glShaderSource(mHandle, 1, src, NULL); glCompileShader(mHandle); GLint compilationResult = GL_FALSE; glGetShaderiv(mHandle, GL_COMPILE_STATUS, &compilationResult); if( logMessage ) *logMessage = GetShaderBuildInfo(mHandle); if( !compilationResult ) return false; mType = type; return true; }
const char *c_str() const { return _impl.c_str(); }
bool VDirAdapter_Unix::exists(const VString &strPath) const { struct stat s; int result = stat(strPath.c_str(), &s); return (result == 0); }