QString probePath(const QString& probeABI) { #ifndef GAMMARAY_INSTALL_QT_LAYOUT return rootPath() + QDir::separator() + QLatin1String(GAMMARAY_PLUGIN_INSTALL_DIR) + QDir::separator() + QLatin1String(GAMMARAY_PLUGIN_VERSION) + QDir::separator() + probeABI; #else Q_UNUSED(probeABI); return rootPath() + QDir::separator() + QLatin1String(GAMMARAY_PROBE_INSTALL_DIR); #endif }
Foam::fileName Foam::IOobject::filePath() const { fileName path = this->path(); fileName objectPath = path/name(); if (isFile(objectPath)) { return objectPath; } else { if ( time().processorCase() && ( instance() == time().system() || instance() == time().constant() ) ) { fileName parentObjectPath = rootPath()/caseName() /".."/instance()/db_.dbDir()/local()/name(); if (isFile(parentObjectPath)) { return parentObjectPath; } } if (!isDir(path)) { word newInstancePath = time().findInstancePath(instant(instance())); if (newInstancePath.size()) { fileName fName ( rootPath()/caseName() /newInstancePath/db_.dbDir()/local()/name() ); if (isFile(fName)) { return fName; } } } } return fileName::null; }
QString QFileSystemEngine::homePath() { QString home = QFile::decodeName(qgetenv("HOME")); if (home.isNull()) home = rootPath(); return QDir::cleanPath(home); }
const c8 * MusicMng::get_list_item_name(s32 pos) { if (pos >= 0 && pos < (s32)m_list.size()) { namespace fs = boost::filesystem; #ifdef UNICODE STRING strPath = m_list[pos]; #else std::wstring strPath = Helper::Utf8ToUtf16(m_list[pos].c_str()); #endif fs::path rootPath(fs::initial_path()); // 初始化为本项目路径 rootPath = fs::system_complete(fs::path(strPath, fs::native)); //将相对路径转换为绝对路径 #ifdef UNICODE static std::string tmp; tmp = Helper::Utf16ToUtf8(rootPath.leaf().c_str()); return tmp.c_str(); #else static std::string tmp; tmp = rootPath.leaf().c_str(); return tmp.c_str(); #endif } return "empty"; }
DataTrace::DataTrace(YouBotJoint& youBotJoint, const std::string Name):joint(youBotJoint) { // Bouml preserved body begin 000C8F71 roundsPerMinuteSetpoint.rpm = 0; PWMSetpoint.pwm = 0; encoderSetpoint.encoderTicks = 0; this->name = Name; if(Name != ""){ this->path = Name; this->path.append("/"); } if(boost::filesystem::exists((path+"jointDataTrace").c_str())){ std::cout << "Do you want to overwrite the existing files? [n/y]" << std::endl; char input = getchar(); if(input!= 'y'){ throw std::runtime_error("Will not overwrite files!"); } }else{ boost::filesystem::path rootPath (this->path); if ( !boost::filesystem::create_directories( rootPath )) throw std::runtime_error("could not create folder!"); } // Bouml preserved body end 000C8F71 }
bool IsFilenameOnFATVolume(const wchar_t *pszFilename) { VDStringW rootPath(VDFileGetRootPath(pszFilename)); if (VDIsWindowsNT()) { DWORD dwMaxComponentLength; DWORD dwFSFlags; wchar_t szFilesystem[MAX_PATH]; if (!GetVolumeInformationW(rootPath.c_str(), NULL, 0, // Volume name buffer NULL, // Serial number buffer &dwMaxComponentLength, &dwFSFlags, szFilesystem, MAX_PATH)) return false; return !_wcsnicmp(szFilesystem, L"FAT", 3); } else { DWORD dwMaxComponentLength; DWORD dwFSFlags; char szFilesystem[MAX_PATH]; if (!GetVolumeInformationA(VDTextWToA(rootPath).c_str(), NULL, 0, // Volume name buffer NULL, // Serial number buffer &dwMaxComponentLength, &dwFSFlags, szFilesystem, sizeof szFilesystem)) return false; return !_strnicmp(szFilesystem, "FAT", 3); } }
int Dialog::verifyFields() { QMessageBox messageBox; string velStr(velocityLineEdit->text().toStdString()); string portStr(portLineEdit->text().toStdString()); QString rootStr = rootLineEdit->text(); QFile rootPath(rootStr); int vel = strtol(velStr.c_str(), NULL, numberBase); int port = strtol(portStr.c_str(), NULL, numberBase); if (rootStr.size() > 0 && !rootPath.exists()) { messageBox.information(this, "Invalid root path", "It's not a valid server root path"); return -1; } if (velStr.size() > 0 && (1 > vel || 10240000 < vel)) { messageBox.information(this, "Invalid parameter", "Invalid velocity number!" "\nInterval: (0, 10240000]"); return -1; } if (portStr.size() > 0 && (1024 > port || 65535 < port)) { messageBox.information(this, "Invalid parameter", "Invalid port number!" "\nInterval: [1024, 65535]"); return -1; } return 0; }
QString QFSFileEngine::homePath() { QString home = QFile::decodeName(qgetenv("HOME")); if (home.isNull()) home = rootPath(); return home; }
void RPCHandler::doGet() { DBG("\r\nIn RPCHandler::doGet()\r\n"); char resp[RPC_DATA_LEN] = {0}; char req[RPC_DATA_LEN] = {0}; DBG("\r\nPath : %s\r\n", path().c_str()); DBG("\r\nRoot Path : %s\r\n", rootPath().c_str()); //Remove path strncpy(req, path().c_str(), RPC_DATA_LEN-1); DBG("\r\nRPC req : %s\r\n", req); //Remove %20, +, from req cleanReq(req); DBG("\r\nRPC req : %s\r\n", req); //Do RPC Call mbed::rpc(req, resp); //FIXME: Use bool result //Response setContentLen( strlen(resp) ); //Make sure that the browser won't cache this request respHeaders()["Cache-control"]="no-cache;no-store"; // respHeaders()["Cache-control"]="no-store"; respHeaders()["Pragma"]="no-cache"; respHeaders()["Expires"]="0"; //Write data respHeaders()["Connection"] = "close"; writeData(resp, strlen(resp)); DBG("\r\nExit RPCHandler::doGet()\r\n"); }
// Returns a new ModelNode for the given model name scene::INodePtr PicoModelLoader::loadModel(const std::string& modelName) { // Initialise the paths, this is all needed for realisation std::string path = rootPath(modelName); std::string name = os::getRelativePath(modelName, path); // greebo: Path is empty for models in PK4 files, don't check this // Try to load the model from the given VFS path IModelPtr model = GlobalModelCache().getModel(name); if (model == NULL) { rError() << "PicoModelLoader: Could not load model << " << modelName << std::endl; return scene::INodePtr(); } // The cached model should be an PicoModel, otherwise we're in the wrong movie RenderablePicoModelPtr picoModel = std::dynamic_pointer_cast<RenderablePicoModel>(model); if (picoModel != NULL) { // Load was successful, construct a modelnode using this resource return PicoModelNodePtr(new PicoModelNode(picoModel)); } else { rError() << "PicoModelLoader: Cached model is not a PicoModel?" << std::endl; } return scene::INodePtr(); }
QString currentPluginsPath() { #ifndef GAMMARAY_INSTALL_QT_LAYOUT return probePath(QStringLiteral(GAMMARAY_PROBE_ABI)); #else return rootPath() + QDir::separator() + QStringLiteral(GAMMARAY_PLUGIN_INSTALL_DIR); #endif }
Foam::fileName Foam::IOobject::path ( const word& instance, const fileName& local ) const { return rootPath()/caseName()/instance/db_.dbDir()/local; }
void purge( const boost::program_options::variables_map & options ) { boost::filesystem::path rootPath( options[ "objectStoreRootPath" ].as< std::string >() ); Osmosis::ObjectStore::Store store( rootPath ); Osmosis::ObjectStore::Labels labels( rootPath, store ); Osmosis::ObjectStore::Purge purge( store, labels ); purge.purge(); }
void ResourceLibraryDialog::ConstructList() { wxLogNull noLogPlease; listCtrl->ClearAll(); wxImageList * imageList = new wxImageList(40,40); imageList->Add(gd::CommonBitmapProvider::Get()->parentFolder40); //If we are in the root path, do not display Parent folder item wxFileName currentDirPath(currentDir); currentDirPath.Normalize(); wxFileName rootPath(wxGetCwd()+"/Free resources/"); rootPath.Normalize(); if ( currentDirPath.GetFullPath() != rootPath.GetFullPath() ) listCtrl->InsertItem(0, _("Parent folder"), 0); //Browse file and directories wxDir dir(currentDir); wxString filename; bool cont = dir.GetFirst(&filename, "", wxDIR_DEFAULT); while ( cont ) { if ( wxDirExists(currentDir+"/"+filename) ) { //Only add a directory if there is a GDLibrary.txt file inside it. if ( wxFileExists(currentDir+"/"+filename+"/GDLibrary.txt") ) { wxBitmap folderBmp = gd::CommonBitmapProvider::Get()->folder40; if ( wxFileExists(currentDir+"/"+filename+"/GDLibraryIcon.png") ) PasteBitmap(folderBmp, wxBitmap(currentDir+"/"+filename+"/GDLibraryIcon.png", wxBITMAP_TYPE_ANY), 20,20 ); imageList->Add(folderBmp); listCtrl->InsertItem(1, filename, imageList->GetImageCount()-1); } } else { //Do not display the library icon if ( filename != "GDLibraryIcon.png" ) { wxLogNull noLogPlease; wxBitmap bmp(currentDir+"/"+filename, wxBITMAP_TYPE_ANY); if ( bmp.IsOk() ) { wxBitmap resizedBmp = Rescale(bmp,40,40); imageList->Add(resizedBmp); listCtrl->InsertItem(listCtrl->GetItemCount(), filename, imageList->GetImageCount()-1); } } } cont = dir.GetNext(&filename); } listCtrl->AssignImageList(imageList, wxIMAGE_LIST_NORMAL); }
const Env::file_path Env::resolveFilePath(const Env::file_path &file) { std::stringstream ss; std::string parentPath = rootPath(); ss << parentPath << "/" << plugin.LibraryPath << "/" << file << plugin::LIBRARY_EXTENSION; return (ss.str()); }
void dumpLabelLog( const boost::program_options::variables_map & options ) { boost::filesystem::path rootPath( options[ "objectStoreRootPath" ].as< std::string >() ); Osmosis::ObjectStore::LabelLogIterator iterator( rootPath ); for ( ; not iterator.done(); iterator.next() ) { auto & entry = * iterator; std::cout << entry.time << '\t' << static_cast< char >( entry.operation ) << '\t' << entry.label << std::endl; } }
Foam::fileName Foam::IOobject::path ( const word& instance, const fileName& local ) const { //Note: can only be called with relative instance since is word type return rootPath()/caseName()/instance/db_.dbDir()/local; }
QString currentPluginsPath() { #ifndef GAMMARAY_INSTALL_QT_LAYOUT return currentProbePath(); #else return rootPath() + QDir::separator() + QLatin1String(GAMMARAY_PLUGIN_INSTALL_DIR); #endif }
DataTrace::DataTrace(YouBotJoint& youBotJoint, const std::string Name, const bool overwriteFiles) : joint(youBotJoint) { // Bouml preserved body begin 000C8F71 roundsPerMinuteSetpoint.rpm = 0; PWMSetpoint.pwm = 0; encoderSetpoint.encoderTicks = 0; InverseMovementDirection invertDirectionParameter; joint.getConfigurationParameter(invertDirectionParameter); bool inverted = false; invertDirectionParameter.getParameter(inverted); if (inverted) { invertDirection = -1; } else { invertDirection = 1; } this->name = Name; if (Name != "") { this->path = Name; this->path.append("/"); } char input = 0; if (boost::filesystem::exists((path + "jointDataTrace").c_str())) { while (input != 'y' && input != 'n' && overwriteFiles == false) { std::cout << "Do you want to overwrite the existing files? [n/y]" << std::endl; input = getchar(); if (input == 'n') { throw std::runtime_error("Will not overwrite files!"); } } } else { boost::filesystem::path rootPath(this->path); if (!boost::filesystem::create_directories(rootPath)) throw std::runtime_error("could not create folder!"); } // Bouml preserved body end 000C8F71 }
bool ModelFilter::filterAcceptsRow(const int source_row, const QModelIndex& source_parent) const { // https://stackoverflow.com/questions/12053502 auto model = qobject_cast<QFileSystemModel*>(sourceModel()); if (model && source_parent != model->index(model->rootPath())) return true; return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); }
void realise () { ASSERT_MESSAGE(m_unrealised != 0, "ModelResource::realise: already realised"); if (--m_unrealised == 0) { m_path = rootPath(m_originalName); m_name = path_make_relative(m_originalName, m_path); m_observers.realise(); } }
Foam::fileName Foam::IOobject::path() const { if (instance().isAbsolute()) { return instance(); } else { return rootPath()/caseName()/instance()/db_.dbDir()/local(); } }
void SystemProcessPath::Pathstr(std::string str) { boost::filesystem::path rootPath( str ); if( exists( rootPath ) ) { if( is_directory( rootPath ) ) ScanDirectory( rootPath ); else outputFileInfo( rootPath ); } }
bool LetterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { if (!sourceParent.isValid()) return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); QModelIndex const childIndex = sourceParent.child(sourceRow, 0); bool const isDir = sourceFileSystemModel()->isDir(childIndex); if (isDir) return rootPath().contains(sourceFileSystemModel()->filePath(childIndex), Qt::CaseSensitive); return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); }
void server( const boost::program_options::variables_map & options ) { boost::filesystem::path rootPath( options[ "objectStoreRootPath" ].as< std::string >() ); unsigned short port = options[ "serverTCPPort" ].as< unsigned short >(); boost::asio::ip::tcp::endpoint endpoint( boost::asio::ip::tcp::v4(), port ); Osmosis::ObjectStore::Store store( rootPath ); Osmosis::ObjectStore::Drafts drafts( rootPath ); Osmosis::ObjectStore::Labels labels( rootPath, store ); Osmosis::Server::Server server( rootPath, endpoint, store, drafts, labels ); server.run(); }
void leastRecentlyUsed( const boost::program_options::variables_map & options ) { boost::filesystem::path rootPath( options[ "objectStoreRootPath" ].as< std::string >() ); std::string keepRegex = options[ "keep" ].as< std::string >(); boost::regex testExpression( keepRegex ); size_t maximumDiskUsage = parseSizeArgument( options[ "maximumDiskUsage" ].as< std::string >() ); Osmosis::ObjectStore::Store store( rootPath ); Osmosis::ObjectStore::Labels labels( rootPath, store ); Osmosis::ObjectStore::LeastRecentlyUsed leastRecentlyUsed( rootPath, store, labels, keepRegex, maximumDiskUsage ); leastRecentlyUsed.go(); }
void realise() { ASSERT_MESSAGE(m_unrealised != 0, "ModelResource::realise: already realised"); if(--m_unrealised == 0) { m_path = rootPath(m_originalName.c_str()); m_name = path_make_relative(m_originalName.c_str(), m_path.c_str()); //globalOutputStream() << "ModelResource::realise: " << m_path.c_str() << m_name.c_str() << "\n"; m_observers.realise(); } }
std::string PointsFileSystem::getPointsFolder(int frame) { QModelIndex root_index = index(rootPath()); int start, end; getFrameRange(start, end); if (start < 0 || end < 0) return std::string(); std::string folder; QString root_path = rootPath(); if (root_path.contains("frame_")) { folder = root_path.toStdString(); } else if (root_path.contains("points")) { // not work ?? /*std::cout << root_path.toStdString() << std::endl; QModelIndex frame_index = index(frame-start, 0, root_index); folder = filePath(frame_index).toStdString();*/ QString frame_name(QString("frame_%1").arg(frame, 5, 10, QChar('0'))); QStringList root_entries = QDir(root_path).entryList(); for (QStringList::const_iterator root_entries_it = root_entries.begin(); root_entries_it != root_entries.end(); ++ root_entries_it) { if (root_entries_it->compare(frame_name) == 0) { folder = (root_path + QString("/%1").arg(*root_entries_it)).toStdString(); break; } } } return folder; }
sint64 VDGetDiskFreeSpace(const wchar_t *path) { typedef BOOL (WINAPI *tpGetDiskFreeSpaceExA)(LPCSTR lpDirectoryName, PULARGE_INTEGER lpFreeBytesAvailable, PULARGE_INTEGER lpTotalNumberOfBytes, PULARGE_INTEGER lpTotalNumberOfFreeBytes); typedef BOOL (WINAPI *tpGetDiskFreeSpaceExW)(LPCWSTR lpDirectoryName, PULARGE_INTEGER lpFreeBytesAvailable, PULARGE_INTEGER lpTotalNumberOfBytes, PULARGE_INTEGER lpTotalNumberOfFreeBytes); static bool sbChecked = false; static tpGetDiskFreeSpaceExA spGetDiskFreeSpaceExA; static tpGetDiskFreeSpaceExW spGetDiskFreeSpaceExW; if (!sbChecked) { HMODULE hmodKernel = GetModuleHandle("kernel32.dll"); spGetDiskFreeSpaceExA = (tpGetDiskFreeSpaceExA)GetProcAddress(hmodKernel, "GetDiskFreeSpaceExA"); spGetDiskFreeSpaceExW = (tpGetDiskFreeSpaceExW)GetProcAddress(hmodKernel, "GetDiskFreeSpaceExW"); sbChecked = true; } if (spGetDiskFreeSpaceExA) { BOOL success; uint64 freeClient, totalBytes, totalFreeBytes; VDStringW directoryName(path); if (!directoryName.empty()) { wchar_t c = directoryName[directoryName.length()-1]; if (c != L'/' && c != L'\\') directoryName += L'\\'; } if ((LONG)GetVersion() < 0) success = spGetDiskFreeSpaceExA(VDTextWToA(directoryName).c_str(), (PULARGE_INTEGER)&freeClient, (PULARGE_INTEGER)&totalBytes, (PULARGE_INTEGER)&totalFreeBytes); else success = spGetDiskFreeSpaceExW(directoryName.c_str(), (PULARGE_INTEGER)&freeClient, (PULARGE_INTEGER)&totalBytes, (PULARGE_INTEGER)&totalFreeBytes); return success ? (sint64)freeClient : -1; } else { DWORD sectorsPerCluster, bytesPerSector, freeClusters, totalClusters; BOOL success; VDStringW rootPath(VDFileGetRootPath(path)); if ((LONG)GetVersion() < 0) success = GetDiskFreeSpaceA(rootPath.empty() ? NULL : VDTextWToA(rootPath).c_str(), §orsPerCluster, &bytesPerSector, &freeClusters, &totalClusters); else success = GetDiskFreeSpaceW(rootPath.empty() ? NULL : rootPath.c_str(), §orsPerCluster, &bytesPerSector, &freeClusters, &totalClusters); return success ? (sint64)((uint64)sectorsPerCluster * bytesPerSector * freeClusters) : -1; } }
//HRESULT wipeOutArchive(CInArchive *archive, CFileEnumeratorCallback *fileEnumeratorCallback) { HRESULT wipeOutArchive(Client7zHandler *handler, fileItemInfo &v, CFileEnumeratorCallback *fileEnumeratorCallback) { CInArchive *archive; RINOK(handler->openArchive(v, &archive)) boost::scoped_ptr<CInArchive> archiveGuard(archive); CMyComPtr<CArchiveExtractCallback> archiveExtractCallback = new CArchiveExtractCallback(NULL); //CInArchiveImpl *archive_ = dynamic_cast<CInArchiveImpl*>(archive); //CMyComPtr<IInArchive> archiveHandler; //RINOK(archive_->getArchiveHandler(&archiveHandler)) std::wstring rootPath(v.path); rootPath += L"\\"; archiveExtractCallback->Init(archive, fileEnumeratorCallback, rootPath); //RINOK(archiveHandler->Extract(NULL, (UInt32)(Int32)(-1), 0, archiveExtractCallback)) RINOK(archive->Extract(NULL, (UInt32)(Int32)(-1), 0, archiveExtractCallback)) return S_OK; }