int findDir(const char * startDir, const char * dirName, char * outputPath) { char rootPath[500]; // char parentPath[500]; char pathsFound[10][500]; getRootPath(rootPath, 500); // fprintf(stderr, "finding number of possible dirs...\n"); int numPossibleDirs = findPaths(startDir, pathsFound); // fprintf(stderr, "numPossibleDirs: %d\n", numPossibleDirs); if(numPossibleDirs ==0) return 0; int val; for(int i=numPossibleDirs-1; i >=0; i--) // for(int i=0; i<numPossibleDirs; i++) { val =findDirWithBase(pathsFound[i], dirName,outputPath); if(val == 1) return 1; } return 0; // printf("starting at %s and looking for %s\n", rootPath, startDir); // int val = gotoParent(startDir, parentPath); // printf("found base: %s\n", parentPath); // return findDirWithBase(parentPath, dirName,outputPath); }//end int findDir(char * startDir, char * dirName, char * outputPath)
void MeshFileManager::writeSurface(const Surface3D &surface, const QString &path) { QFile file(getRootPath() + path); if (!file.open(QIODevice::WriteOnly)) { return; } QTextStream stream(&file); stream << "MeshVersionFormatted 1" << endl << "Dimension" << endl << "3" << endl; // Writing vertices int pointsCount = surface.getPointsCount(); stream << "Vertices" << endl << pointsCount << endl; for (int i = 0; i < pointsCount; ++i) { stream << surface.getPoint(i).format() << endl; } // Writing triangles int triangleCount = surface.getTrianglesCount(); stream << "Triangles" << endl << triangleCount << endl; for (int i = 0; i < triangleCount; ++i) { stream << surface.getTriangle(i).format() << endl; } stream << "End" << endl; }
void MeshFileManager::writeShape(const Grid3D &grid, const QString &path) { QFile file(getRootPath() + path); if (!file.open(QIODevice::WriteOnly)) { return; } QTextStream stream(&file); stream << "MeshVersionFormatted 1" << endl << "Dimension" << endl << "3" << endl; stream << "Vertices" << endl << grid.getNx() * grid.getNy() * grid.getNz() << endl; for (int z = 0; z < grid.getNz(); ++z) { for (int y = 0; y < grid.getNy(); ++y) { for (int x = 0; x < grid.getNx(); ++x) { Point3D currentPoint(grid.getOrigin().getX() + x, grid.getOrigin().getY() + y, grid.getOrigin().getZ() + z); if (grid.getProperty(currentPoint.getX(), currentPoint.getY(), currentPoint.getZ()) < 0) { stream << currentPoint.format() << endl; } } } } stream << "End" << endl; }
TreePath SceneTreeModel::getLightPath(Light* const LightToSelect) const { TreePath Path(getRootPath()); Path = Path.getChildPath(boost::any(UInt32(LightsComponent))); Path = Path.getChildPath(boost::any(LightToSelect)); return Path; }
void SceneTreeModel::handleViewportFieldsChanged(FieldContainer *fc, ConstFieldMaskArg whichField) { if(whichField & Viewport::ForegroundsFieldMask) { //Send the Foregrounds nodes changed //produceTreeNodesChanged(TreePath Parent, const std::vector<UInt32>& ChildIndices, const std::vector<boost::any>& Children); } else if(whichField & Viewport::BackgroundFieldMask) { //Send the Background node changed TreePath Root(getRootPath()); std::vector<UInt32> ChildIndices; ChildIndices.push_back(getIndexOfChild(getRoot(), boost::any(BackgroundComponent))); std::vector<boost::any> Children; Children.push_back(getChild(getRoot(), ChildIndices.front())); produceTreeNodesChanged(Root, ChildIndices, Children); } else if(whichField & Viewport::CameraFieldMask) { //Send the Camera node changed } else if(whichField & Viewport::RootFieldMask) { } }
TreePath SceneTreeModel::getSceneObjectPath(SceneObject* const ObjToSelect) const { TreePath Path(getRootPath()); Path = Path.getChildPath(boost::any(UInt32(SceneObjectsComponent))); Path = Path.getChildPath(boost::any(ObjToSelect)); return Path; }
void testVPLFS(void) { # ifdef IOS rootPath = getRootPath(); # elif defined(VPL_PLAT_IS_WINRT) getRootPath(&rootPath); # endif #ifdef WIN32 VPLTEST_LOG("testGetExtendedPath"); testGetExtendedPath(); VPLTEST_LOG("testGetKnownFolderPath"); testGetKnownFolderPath(); #endif VPLTEST_LOG("testInvalidParameters."); testInvalidParameters(); VPLTEST_LOG("doStatTest."); if (doStatTest()) { VPLTEST_FAIL("doStatTest."); } # ifndef ANDROID VPLTEST_LOG("doSeekdirTest."); if (doSeekdirTest()) { VPLTEST_FAIL("doSeekdirTest."); } # endif VPLTEST_LOG("doMkdirTest."); if (doMkdirTest()) { VPLTEST_FAIL("doMkdirTest."); } VPLTEST_LOG("doUnlinkTest."); if (doUnlinkTest()) { VPLTEST_FAIL("doUnlinkTest."); } # ifdef VPL_PLAT_IS_WINRT releaseRootPath(rootPath); # endif }
_bstr_t CREBUS::getPage(LPCTSTR name) { _bstr_t path = getRootPath(); path += "\\pages\\"; path += name; path += ".esp"; return path; }
QString LiteApp::getPluginPath() { QString root = getRootPath(); #ifdef Q_OS_MAC return root+"/PlugIns"; #else return root+"/lib/liteide/plugins"; #endif }
QString LiteApp::getResoucePath() { QString root = getRootPath(); #ifdef Q_OS_MAC return root+"/Resources"; #else return root+"/share/liteide"; #endif }
void MeshFileManager::writeGeometry(const Grid3D &grid, const QString &path) { QFile file(getRootPath() + path); if (!file.open(QIODevice::WriteOnly)) { return; } QTextStream stream(&file); stream << "MeshVersionFormatted 1" << endl << "Dimension" << endl << "3" << endl; int nx = grid.getNx(); int ny = grid.getNy(); int nz = grid.getNz(); Point3D origin = grid.getOrigin(); stream << "Vertices" << endl << nx * ny * nz << endl; QVector<Hexaedra> hexs; int xD = 1; int yD = nx; int zD = nx * ny; for (int z = 0; z < nz; ++z) { for (int y = 0; y < ny; ++y) { for (int x = 0; x < nx; ++x) { stream << Point3D(origin.getX() + x, origin.getY() + y, origin.getZ() + z).format() << endl; if (!(x == nx - 1 || y == ny - 1 || z == nz - 1)) { hexs.push_back(Hexaedra( xD * (x + 0) + yD * (y + 0) + zD * (z + 0), xD * (x + 1) + yD * (y + 0) + zD * (z + 0), xD * (x + 1) + yD * (y + 1) + zD * (z + 0), xD * (x + 0) + yD * (y + 1) + zD * (z + 0), xD * (x + 0) + yD * (y + 0) + zD * (z + 1), xD * (x + 1) + yD * (y + 0) + zD * (z + 1), xD * (x + 1) + yD * (y + 1) + zD * (z + 1), xD * (x + 0) + yD * (y + 1) + zD * (z + 1) )); } } } } stream << "Hexahedra" << endl << hexs.size() << endl; for (int i = 0; i < hexs.size(); ++i) { stream << hexs.at(i).format() << endl; } stream << "End" << endl; }
bool Info::init(const String &path) { _file = cocos2d::unzOpen2_64((void *)&path, &s_fileApi.pathFunc); if (_file) { _manifest = getFileList(_file); _rootFile = getRootPath(); _rootPath = filepath::root(_rootFile); processPublication(); } return valid(); }
HRESULT Drive::Mount() { // Get our serial LoadSerial(); // Get our serial as a string CHAR serialStr[41]; serialStr[40] = 0; UINT outLen = 0x40; GetBytesString(m_Serial, 0x14, serialStr, &outLen); m_SerialStr = (string)serialStr; if (m_DriveType == DEVICE_USBMEMORY_UNIT0 || m_DriveType == DEVICE_USBMEMORY_UNIT1 || m_DriveType == DEVICE_USBMEMORY_UNIT2 ) m_SerialStr = m_SerialStr + "_USBMU"; if (m_DriveType == DEVICE_USBMEMORY_Cache0 || m_DriveType == DEVICE_USBMEMORY_Cache1 || m_DriveType == DEVICE_USBMEMORY_Cache2 ) m_SerialStr = m_SerialStr + "_USBMUC"; //DebugMsg("Mounting %s",m_MountPoint.c_str()); char MountConv[260]; sprintf_s( MountConv, "\\??\\%s", m_MountPoint.c_str() ); char SysPath[260]; sprintf_s( SysPath,"%s", m_SystemPath.c_str() ); STRING sSysPath = { (USHORT)strlen( SysPath ), (USHORT)strlen( SysPath ) + 1, SysPath }; STRING sMountConv = { (USHORT)strlen( MountConv ), (USHORT)strlen( MountConv ) + 1, MountConv }; //don't try to mount 'Game:' as it's already there if (stricmp(m_MountPoint.c_str(), "Game:") != 0) { int res = ObCreateSymbolicLink( &sMountConv, &sSysPath ); if (res != 0) { //DebugMsg("Mount failed : %d",res); return res; } } HRESULT ret = IsMounted(); if(ret == 1) { GetDiskFreeSpaceEx(getRootPath().c_str(),&m_FreeBytesAvailable,&m_TotalNumberOfBytes,&m_TotalNumberOfFreeBytes); } else { m_FreeBytesAvailable.QuadPart = 0; m_TotalNumberOfBytes.QuadPart =0; m_TotalNumberOfFreeBytes.QuadPart=0; } return ret; }
void SceneTreeModel::setRoot(Scene* const root) { dettachChangedFunctors(); _ViewportFieldsChangedContainer = root->getPrimaryViewport(); _SceneFieldsChangedContainer = root; attachChangedFunctors(); setInternalRoot(root); std::vector<UInt32> ChildIndices; std::vector<boost::any> Children; produceTreeStructureChanged(getRootPath(), ChildIndices, Children); }
QString LiteApp::getResoucePath() { static QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QString path = env.value("LITEIDE_RES_PATH"); if (!path.isEmpty()) { return path; } QString root = getRootPath(); #ifdef Q_OS_MAC return root+"/Resources"; #else return root+"/share/liteide"; #endif }
QString LiteApp::getPluginPath() { static QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QString path = env.value("LITEIDE_PLUGIN_PATH"); if (!path.isEmpty()) { return path; } QString root = getRootPath(); #ifdef Q_OS_MAC return root+"/PlugIns"; #else return root+"/lib/liteide/plugins"; #endif }
int ConfigCtx::getAbsolute(char *res, const char *path, int pathOnly) { const char *pChroot = MainServerConfig::getInstance().getChroot(); int iChrootLen = MainServerConfig::getInstance().getChrootlen(); const char *pRoot = ""; const char *pPath = path; int ret; char achBuf[MAX_PATH_LEN]; char *dest = achBuf; int len = MAX_PATH_LEN; if (getRootPath(pRoot, pPath)) return LS_FAIL; if (pChroot) { if ((*pRoot) || (strncmp(path, pChroot, iChrootLen) != 0)) { memmove(dest, pChroot, iChrootLen); dest += iChrootLen; len -= iChrootLen; } } if (pathOnly) ret = GPath::getAbsolutePath(dest, len, pRoot, pPath); else ret = GPath::getAbsoluteFile(dest, len, pRoot, pPath); if (ret) { LS_ERROR(this, "Failed to tanslate to absolute path with root=%s, " "path=%s!", pRoot, path); } else { // replace "$VH_NAME" with the real name of the virtual host. if (expandVariable(achBuf, res, MAX_PATH_LEN) < 0) { LS_NOTICE(this, "Path is too long: %s", pPath); return LS_FAIL; } } return ret; }
void ComponentTreeModel::changed(ConstFieldMaskArg whichField, UInt32 origin, BitVector details) { Inherited::changed(whichField, origin, details); //Do not respond to changes that have a Sync origin if(origin & ChangedOrigin::Sync) { return; } if(whichField & InternalRootComponentFieldMask) { produceTreeStructureChanged(getRootPath(),std::vector<UInt32>(1, 0),std::vector<boost::any>(1, getRoot())); } }
int WsUser::writeFile(const std::string path, const std::string& text){ int ret = getPermissions(path); if(ret == ErrorCode::NotFound) return ret; if(ret != GlobalConfig::ReadWrite) return ErrorCode::NoAccess; ofstream myfile; std::string p = getRootPath() + "/"+path; myfile.open (p.c_str()); if(myfile.is_open()){ myfile << text; myfile.close(); return ErrorCode::Success; } return ErrorCode::Failure; }
int findFile(const char * startDir, const char * fileName, char * outputPath) { char rootPath[500]; // char parentPath[500]; char pathsFound[10][500]; getRootPath(rootPath, 500); int numPossibleDirs = findPaths(startDir, pathsFound); if(numPossibleDirs ==0) return 0; int val; for(int i=0; i<numPossibleDirs; i++) { val =findFileWithBase(pathsFound[i], fileName,outputPath); if(val == 1) return 1; } return 0; }//end int findFile(char * startDir, char * fileName, char * outputPath)
void FieldContainerTreeModel::changed(ConstFieldMaskArg whichField, UInt32 origin, BitVector details) { Inherited::changed(whichField, origin, details); if(whichField & (InternalRootFieldContainerFieldMask | ShowInternalFieldsFieldMask | ShowMultiFieldsFieldMask | ShowSingleFieldsFieldMask | ShowPtrFieldsFieldMask | ShowDataFieldsFieldMask | ShowParentPtrFieldsFieldMask | ShowChildPtrFieldsFieldMask | ShowAttachmentsFieldMask | ShowCallbackFunctorsFieldMask) ) { produceTreeStructureChanged(getRootPath(),std::vector<UInt32>(1, 0),std::vector<boost::any>(1, getRoot())); } }
Surface3D MeshFileManager::readSurface(const QString &path) { // Opening the file QFile file(getRootPath() + path); if(!file.open(QIODevice::ReadOnly)) { return Surface3D(); } QTextStream in(&file); // Skipping useless lines in.readLine(); in.readLine(); in.readLine(); in.readLine(); // The full surface Surface3D surface; // Vertices int verticesCount = in.readLine().toInt(); for (int i = 0; i < verticesCount; ++i) { QString line = in.readLine().trimmed(); QStringList fields = line.split(" "); surface.addNode(Node(fields[0].toDouble(), fields[1].toDouble(), fields[2].toDouble())); } // Triangles in.readLine(); // Skipping "Triangles" int trianglesCount = in.readLine().toInt(); for (int i = 0; i < trianglesCount; ++i) { QString line = in.readLine().trimmed(); QStringList fields = line.split(" "); surface.addTriangle(Triangle(fields[0].toInt() - 1, fields[1].toInt() - 1, fields[2].toInt() - 1)); } file.close(); return surface; }
/** * @brief Process an incoming HTTP request. * * We look at the path of the request and see if it has a matching path handler. If it does, * we invoke the handler function. If it does not, we try and find a file on the file system * that would resolve to the path. * * @param [in] mgConnection The network connection on which the request was received. * @param [in] message The message representing the request. */ void WebServer::processRequest(struct mg_connection *mgConnection, struct http_message* message) { std::string uri = mgStrToString(message->uri); ESP_LOGD(tag, "WebServer::processRequest: Matching: %s", uri.c_str()); HTTPResponse httpResponse = HTTPResponse(mgConnection); httpResponse.setRootPath(getRootPath()); /* * Iterate through each of the path handlers looking for a match with the method and specified path. */ std::vector<PathHandler>::iterator it; for (it = m_pathHandlers.begin(); it != m_pathHandlers.end(); ++it) { if ((*it).match(mgStrToString(message->method), uri)) { HTTPRequest httpRequest(message); (*it).invoke(&httpRequest, &httpResponse); ESP_LOGD(tag, "Found a match!!"); return; } } // End of examine path handlers. // Because we reached here, it means that we did NOT match a handler. Now we want to attempt // to retrieve the corresponding file content. std::string filePath = httpResponse.getRootPath() + uri; ESP_LOGD(tag, "Opening file: %s", filePath.c_str()); FILE *file = fopen(filePath.c_str(), "r"); if (file != nullptr) { fseek(file, 0L, SEEK_END); size_t length = ftell(file); fseek(file, 0L, SEEK_SET); uint8_t *pData = (uint8_t *)malloc(length); fread(pData, length, 1, file); fclose(file); httpResponse.sendData(pData, length); free(pData); } else { // Handle unable to open file httpResponse.setStatus(404); // Not found httpResponse.sendData(""); } } // processRequest
void MeshFileManager::writeShapePoints(const Grid3D &grid, const QString &path) { QVector<Point3D> points = grid.getShapePoints(); QFile file(getRootPath() + path); if (!file.open(QIODevice::WriteOnly)) { return; } QTextStream stream(&file); stream << "MeshVersionFormatted 1" << endl << "Dimension" << endl << "3" << endl; stream << "Vertices" << endl << points.size() << endl; for (int i = 0; i < points.size(); ++i) { stream << points[i].format() << endl; } stream << "End" << endl; }
void SceneTreeModel::sceneObjectRemoved(SceneObject* const TheSceneObject) { TreePath Parent(getRootPath(), boost::any(UInt32(SceneObjectsComponent))); produceTreeNodeRemoved(Parent, boost::any(TheSceneObject)); }
void SceneTreeModel::foregroundWillBeRemoved(Foreground* const TheForeground) { TreePath Parent(getRootPath(), boost::any(UInt32(ForegroundsComponent))); produceTreeNodeWillBeRemoved(Parent, boost::any(TheForeground)); }
void SceneTreeModel::lightRemoved(Light* const TheLightNode) { TreePath Parent(getRootPath(), boost::any(UInt32(LightsComponent))); produceTreeNodeRemoved(Parent, boost::any(TheLightNode)); }
int ConfigCtx::expandVariable(const char *pValue, char *pBuf, int bufLen, int allVariable) { const char *pBegin = pValue; char *pBufEnd = pBuf + bufLen - 1; char *pCur = pBuf; int len; while (*pBegin) { len = strcspn(pBegin, "$"); if (len > 0) { if (len > pBufEnd - pCur) return LS_FAIL; memmove(pCur, pBegin, len); pCur += len; pBegin += len; } if (*pBegin == '$') { if (strncasecmp(pBegin + 1, VH_NAME, 7) == 0) { pBegin += 8; int nameLen = s_vhName.len(); if (nameLen > 0) { if (nameLen > pBufEnd - pCur) return LS_FAIL; memmove(pCur, s_vhName.c_str(), nameLen); pCur += nameLen; } } else if ((allVariable) && ((strncasecmp(pBegin + 1, VH_ROOT, 7) == 0) || (strncasecmp(pBegin + 1, DOC_ROOT, 8) == 0) || (strncasecmp(pBegin + 1, SERVER_ROOT, 11) == 0))) { const char *pRoot = ""; getRootPath(pRoot, pBegin); if (*pRoot) { int len = strlen(pRoot); if (len > pBufEnd - pCur) return LS_FAIL; memmove(pCur, pRoot, len); pCur += len; } } else { if (pCur == pBufEnd) return LS_FAIL; *pCur++ = '$'; ++pBegin; } } } *pCur = 0; return pCur - pBuf; }
TreePath SceneTreeModel::getCameraPath(void) const { TreePath Path(getRootPath()); Path = Path.getChildPath(boost::any(UInt32(CameraComponent))); return Path; }