本文整理汇总了C++中poco::Path::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ Path::toString方法的具体用法?C++ Path::toString怎么用?C++ Path::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poco::Path
的用法示例。
在下文中一共展示了Path::toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveConfig
void XplDevice::SaveConfig()
{
Poco::Path p = GetConfigFileLocation();
poco_debug ( devLog, "saving config for " + GetCompleteId() + " to " + p.toString());
m_configStore->setString("vendorId", GetVendorId());
m_configStore->setString("deviceId", GetDeviceId());
m_configStore->setString("instanceId", GetInstanceId());
if(m_configItems.size()) {
m_configStore->setInt("configItems",m_configItems.size());
for ( vector<AutoPtr<XplConfigItem> >::iterator iter = m_configItems.begin(); iter != m_configItems.end(); ++iter )
{
poco_debug ( devLog, "saving config item " + (*iter)->GetName());
m_configStore->setString("configItems." + (*iter)->GetName(), "" );
m_configStore->setString("configItems." + (*iter)->GetName() + ".numValues" , NumberFormatter::format((*iter)->GetNumValues()) );
for (int vindex=0; vindex<(*iter)->GetNumValues(); vindex++) {
m_configStore->setString("configItems." + (*iter)->GetName() + ".value" + NumberFormatter::format(vindex) , (*iter)->GetValue(vindex) );
}
}
}
m_configStore->save(p.toString());
poco_debug ( devLog, "saved to " + p.toString());
}
示例2: deltree
// recusively delete the path given. we do this manually to set the permissions to writable,
// so that windows doesn't cause permission denied errors.
cResult deltree(Poco::Path s)
{
drunner_assert(s.isDirectory(), "deltree: asked to delete a file: "+s.toString());
cResult rval = kRNoChange;
try
{
Poco::DirectoryIterator end;
for (Poco::DirectoryIterator it(s); it != end; ++it)
if (it->isFile())
rval += delfile(it->path());
else
{
Poco::Path subdir(it->path());
subdir.makeDirectory();
rval += deltree(subdir);
}
Poco::File f(s);
f.setWriteable(true);
f.remove();
logmsg(kLDEBUG, "Deleted " + f.path());
}
catch (const Poco::Exception & e) {
return cError("Couldn't delete " + s.toString() + " - " + e.what());
}
return kRSuccess;
}
示例3: validateDir
// ---
bool VSWAEImportContentWindow::validateDir (const QString& d)
{
bool result = false;
// Calculates the paths for everything: the basic dir, the definition file...
// ...and the basic path received as parameter during the initialization.
Poco::Path defPath;
Poco::File defFile;
Poco::File defDir (d.toStdString ());
Poco::Path bPath (_basicPath.toStdString ());
bool isDefDirADir = defDir.isDirectory (); // The directory has to be a dir (this is guarantte by the window, but just in case)
if (isDefDirADir)
{
defPath = Poco::Path (d.toStdString ());
defFile = Poco::File ((d + QString (__PATH_SEPARATOR__) +
_name -> text () + QString (".xml")).toStdString ());
}
// If the directory is a directory, then it is needed to test whether the
// directory is or not contained in the basic path received as parameter.
bool isDefDirInBPath = false;
if (isDefDirADir)
isDefDirInBPath = ((defPath.toString () + std::string (__PATH_SEPARATOR__)).
find (bPath.toString () + std::string (__PATH_SEPARATOR__)) != -1);
// To determinate whether the dir is or not valid...
result = !isDefDirADir || (isDefDirADir && isDefDirInBPath);
return (result);
}
示例4: DoImportGameStrings
int CStatsUtil::DoImportGameStrings()
{
Poco::Path inpath(m_inputPath);
Poco::Path outpath;
if( m_outputPath.empty() )
throw runtime_error("Output path unspecified!");
if( utils::isFolder( m_outputPath ) )
{
outpath = Poco::Path(m_outputPath).makeAbsolute().makeDirectory();
GameStats gstats( outpath.toString(), m_langconf );
gstats.AnalyzeGameDir();
gstats.ImportStrings( m_inputPath );
gstats.WriteStrings();
}
else
{
outpath = Poco::Path(m_outputPath).makeAbsolute();
if( ! m_flocalestr.empty() )
{
auto myloc = std::locale( m_flocalestr );
pmd2::filetypes::WriteTextStrFile( outpath.toString(), utils::io::ReadTextFileLineByLine( m_inputPath, myloc ), myloc );
}
else
{
pmd2::filetypes::WriteTextStrFile( outpath.toString(), utils::io::ReadTextFileLineByLine(m_inputPath) );
}
}
return 0;
}
示例5: setPath
/**
* Sets the location of the module given an absolute or relative location.
* For relative paths we look for the
* module first in PROG_DIR, then MODULE_DIR, then the
* current directory, and
* finally the system path. Will throw an exception if the module cannot
* be found.
* @param location Absolute or relative path string for module.
*/
void TskModule::setPath(const std::string& location)
{
if (location.empty())
{
throw TskException("TskModule::setPath: location is empty or missing.");
}
Poco::Path tempPath = location;
if (!tempPath.isAbsolute())
{
// If this is a relative path, then see if we can find the
// executable either in PROG_DIR, in MODULE_DIR, in the current directory,
// or on the system path.
std::string pathsToSearch = GetSystemProperty(TskSystemProperties::PROG_DIR);
if (!pathsToSearch.empty())
pathsToSearch += Poco::Path::pathSeparator();
pathsToSearch += GetSystemProperty(TskSystemProperties::MODULE_DIR);
if (!pathsToSearch.empty())
pathsToSearch += Poco::Path::pathSeparator();
pathsToSearch += ".";
if (!Poco::Path::find(pathsToSearch, location, tempPath))
{
// if we didn't find them in the above paths, check on the path.
if (Poco::Environment::has("Path"))
{
std::string systemPath = Poco::Environment::get("Path");
if (!systemPath.empty())
{
Poco::Path::find(systemPath, location, tempPath);
}
}
}
}
// Confirm existence of file at location.
Poco::File moduleFile(tempPath);
if (!moduleFile.exists())
{
std::stringstream msg;
msg << "TskModule::setPath - Module not found: "
<< tempPath.toString().c_str();
throw TskException(msg.str());
}
else {
std::wstringstream msg;
msg << L"TskModule::setPath - Module found at: "
<< tempPath.toString().c_str();
LOGINFO(msg.str());
}
m_modulePath = tempPath.toString();
}
示例6: update
void CWidget::update(CWorkerTools::WorkerProgressFunc progressCallback, const std::string & widgetName, const std::string & downloadUrl)
{
YADOMS_LOG(information) << "Updating widget " << widgetName << " from " << downloadUrl;
shared::CDataContainer callbackData;
callbackData.set("widgetName", widgetName);
callbackData.set("downloadUrl", downloadUrl);
progressCallback(true, 0.0f, i18n::CClientStrings::UpdateWidgetUpdate, shared::CStringExtension::EmptyString, callbackData);
/////////////////////////////////////////////
//1. download package
/////////////////////////////////////////////
try
{
YADOMS_LOG(information) << "Downloading widget package";
progressCallback(true, 0.0f, i18n::CClientStrings::UpdateWidgetDownload, shared::CStringExtension::EmptyString, callbackData);
Poco::Path downloadedPackage = CWorkerTools::downloadPackage(downloadUrl, progressCallback, i18n::CClientStrings::UpdateWidgetDownload, 0.0, 90.0);
YADOMS_LOG(information) << "Downloading widget package with sucess";
/////////////////////////////////////////////
//2. deploy package
/////////////////////////////////////////////
try
{
YADOMS_LOG(information) << "Deploy widget package " << downloadedPackage.toString();
progressCallback(true, 90.0f, i18n::CClientStrings::UpdateWidgetDeploy, shared::CStringExtension::EmptyString, callbackData);
Poco::Path widgetPath = CWorkerTools::deployWidgetPackage(downloadedPackage);
YADOMS_LOG(information) << "Widget installed with success";
progressCallback(true, 100.0f, i18n::CClientStrings::UpdateWidgetSuccess, shared::CStringExtension::EmptyString, callbackData);
}
catch (std::exception & ex)
{
//fail to extract package file
YADOMS_LOG(error) << "Fail to deploy widget package : " << ex.what();
progressCallback(false, 100.0f, i18n::CClientStrings::UpdateWidgetDeployFailed, ex.what(), callbackData);
}
//delete downloaded zip file
Poco::File toDelete(downloadedPackage.toString());
if (toDelete.exists())
toDelete.remove();
}
catch (std::exception & ex)
{
//fail to download package
YADOMS_LOG(error) << "Fail to download pwidget ackage : " << ex.what();
progressCallback(false, 100.0f, i18n::CClientStrings::UpdateWidgetDownloadFailed, ex.what(), callbackData);
}
}
示例7: glob
/**
* Creates a set of files that match the given pathPattern.
*
* The path may be give in either Unix, Windows or VMS syntax and
* is automatically expanded by calling Path::expand().
*
* The pattern may contain wildcard expressions even in intermediate
* directory names (e.g. /usr/include/<I>*</I> /<I>*</I>*.h).
*
* Note that, for obvious reasons, escaping characters in a pattern
* with a backslash does not work in Windows-style paths.
*
* Directories that for whatever reason cannot be traversed are
* ignored.
*
* It seems that whatever bug Poco had is fixed now.
* So calling Poco::Glob::glob(pathPattern,files,options) inside.
*
* @param pathPattern :: The search pattern
* @param files :: The names of the files that match the pattern
* @param options :: Options
*/
void Glob::glob(const Poco::Path& pathPattern, std::set<std::string>& files, int options)
{
#ifdef _WIN32
// There appears to be a bug in the glob for windows.
// Putting case sensitive on then with reference to test testFindFileCaseSensitive()
// in FileFinderTest on Windows it is able to find "CSp78173.Raw" as it should even
// the case is wrong, but for some strange reason it then cannot find IDF_for_UNiT_TESTiNG.xMl!!!!
// Hence the reason to circumvent this by this #ifdef
Poco::Glob::glob(Poco::Path(pathPattern.toString()),files, Poco::Glob::GLOB_CASELESS);
#else
Poco::Glob::glob(Poco::Path(pathPattern.toString()),files,options);
#endif
}
示例8: f
tempfolder::tempfolder(Poco::Path d) : mPath(d)
{ // http://stackoverflow.com/a/10232761
Poco::File f(d);
if (f.exists() && kRSuccess != utils::deltree(d))
die("Couldn't delete old stuff in temp directory: " + d.toString());
f.createDirectories();
logmsg(kLDEBUG, "Created " + d.toString());
#ifndef _WIN32
if (chmod(d.toString().c_str(), S_777) != 0)
die("Unable to change permissions on " + d.toString());
#endif
}
示例9: Copy
void AsyncCopy::Copy(Poco::Path &src, Poco::Path &dest)
{
Logger* logger = Logger::Get("Filesystem.AsyncCopy");
std::string srcString = src.toString();
std::string destString = dest.toString();
Poco::File from(srcString);
bool isLink = from.isLink();
logger->Debug("file=%s dest=%s link=%i", srcString.c_str(), destString.c_str(), isLink);
#ifndef OS_WIN32
if (isLink)
{
char linkPath[PATH_MAX];
ssize_t length = readlink(from.path().c_str(), linkPath, PATH_MAX);
linkPath[length] = '\0';
std::string newPath (dest.toString());
const char *destPath = newPath.c_str();
unlink(destPath); // unlink it first, fails in some OS if already there
int result = symlink(linkPath, destPath);
if (result == -1)
{
std::string err = "Copy failed: Could not make symlink (";
err.append(destPath);
err.append(") from ");
err.append(linkPath);
err.append(" : ");
err.append(strerror(errno));
throw kroll::ValueException::FromString(err);
}
}
#endif
if (!isLink && from.isDirectory())
{
Poco::File d(dest.toString());
if (!d.exists())
{
d.createDirectories();
}
std::vector<std::string> files;
from.list(files);
std::vector<std::string>::iterator i = files.begin();
while(i!=files.end())
{
std::string fn = (*i++);
Poco::Path sp(kroll::FileUtils::Join(src.toString().c_str(),fn.c_str(),NULL));
Poco::Path dp(kroll::FileUtils::Join(dest.toString().c_str(),fn.c_str(),NULL));
this->Copy(sp,dp);
}
}
else if (!isLink)
{
// in this case it's a regular file
Poco::File s(src.toString());
s.copyTo(dest.toString().c_str());
}
}
示例10: DoExportAll
int CStatsUtil::DoExportAll()
{
Poco::Path inpath(m_inputPath);
Poco::Path outpath;
if( m_outputPath.empty() )
{
outpath = inpath.absolute().makeParent().append(DefExportAllDir);
}
else
{
outpath = Poco::Path(m_outputPath).makeAbsolute();
}
GameStats gstats( m_inputPath, m_langconf );
gstats.Load();
//Test output path
Poco::File fTestOut = outpath;
if( ! fTestOut.exists() )
{
cout << "Created output directory \"" << fTestOut.path() <<"\"!\n";
fTestOut.createDirectory();
}
gstats.ExportAll(outpath.toString());
return 0;
}
示例11: DoExportGameScripts
int CStatsUtil::DoExportGameScripts()
{
//Validate output + input paths
Poco::Path inpath(m_inputPath);
Poco::Path outpath;
if( m_outputPath.empty() )
outpath = inpath.absolute().makeParent().append(DefExportScriptsDir);
else
outpath = Poco::Path(m_outputPath).makeAbsolute();
Poco::File fTestOut = outpath;
if( ! fTestOut.exists() )
{
cout << "Created output directory \"" << fTestOut.path() <<"\"!\n";
fTestOut.createDirectory();
}
else if( ! fTestOut.isDirectory() )
throw runtime_error("CStatsUtil::DoExportGameScripts(): Output path is not a directory!");
//Setup the script handler
GameScripts scripts( inpath.absolute().toString() );
//Convert to XML
scripts.ExportScriptsToXML( outpath.toString() );
return 0;
}
示例12: inputPath
std::string mui::Helpers::muiPath( std::string path ){
// pretty much copy&pasted from OF
Poco::Path outputPath;
Poco::Path inputPath(path);
string strippedDataPath = mui::MuiConfig::dataPath.toString();
strippedDataPath = ofFilePath::removeTrailingSlash(strippedDataPath);
if (inputPath.toString().find(strippedDataPath) != 0) {
outputPath = mui::MuiConfig::dataPath;
outputPath.resolve(inputPath);
} else {
outputPath = inputPath;
}
if( !ofFile(outputPath.absolute().toString(), ofFile::Reference).exists() ){
// maybe in the data dir?
string dataFile = ofToDataPath(path, true);
if( ofFile(dataFile,ofFile::Reference).exists() ){
outputPath = Poco::Path(dataFile);
}
}
if( mui::MuiConfig::logLevel <= OF_LOG_NOTICE ){
cout << "loading path: " << outputPath.toString() << " || " << outputPath.absolute().toString() << " || " << path << endl;
}
return outputPath.absolute().toString();
}
示例13: ExtractQCHFiles
QStringList QtAssistantUtil::ExtractQCHFiles(const std::vector<IBundle::Pointer>& bundles)
{
QStringList result;
for (std::size_t i = 0; i < bundles.size(); ++i)
{
std::vector<std::string> resourceFiles;
bundles[i]->GetStorage().List("resources", resourceFiles);
bool qchFileFound = false;
for (std::size_t j = 0; j < resourceFiles.size(); ++j)
{
QString resource = QString::fromStdString(resourceFiles[j]);
if (resource.endsWith(".qch"))
{
qchFileFound = true;
Poco::Path qchPath = bundles[i]->GetPath();
qchPath.pushDirectory("resources");
qchPath.setFileName(resourceFiles[j]);
result << QString::fromStdString(qchPath.toString());
}
}
if (qchFileFound)
{
registeredBundles.insert(QString::fromStdString(bundles[i]->GetSymbolicName()));
}
}
return result;
}
示例14: strLibPath
IBundleActivator*
BundleLoader::LoadActivator(BundleInfo& bundleInfo)
{
Poco::Mutex::ScopedLock lock(m_Mutex);
std::string activator = bundleInfo.m_Bundle->GetActivatorClass();
if (activator == "") return new DefaultActivator();
Poco::Path libPath = this->GetLibraryPathFor(bundleInfo.m_Bundle);
std::string strLibPath(libPath.toString());
BERRY_INFO(m_ConsoleLog) << "Loading activator library: " << strLibPath;
try
{
/* retrieves only an empty string and its not required
#ifdef BERRY_OS_FAMILY_WINDOWS
char cDllPath[512];
GetDllDirectory(512, cDllPath);
BERRY_INFO << "Dll Path: " << cDllPath << std::endl;
#endif
*/
bundleInfo.m_ClassLoader->loadLibrary(strLibPath);
return bundleInfo.m_ClassLoader->create(activator);
}
catch (Poco::LibraryLoadException exc)
{
BERRY_ERROR << "Could not create Plugin activator. Did you export the class \"" << activator << "\" ?\n"
<< " Exception displayText(): " << exc.displayText();
exc.rethrow();
}
return 0;
}
示例15: getOFRelPath
string getOFRelPath(string from){
Poco::Path base(true);
base.parse(from);
Poco::Path path;
path.parse( getOFRoot() );
path.makeAbsolute();
cout << "getOFRelPath " << base.toString() << " " << path.toString() << endl;
string relPath;
if (path.toString() == base.toString()){
// do something.
}
int maxx = MAX(base.depth(), path.depth());
for (int i = 0; i <= maxx; i++){
bool bRunOut = false;
bool bChanged = false;
if (i <= base.depth() && i <= path.depth()){
if (base.directory(i) == path.directory(i)){
} else {
bChanged = true;
}
} else {
bRunOut = true;
}
if (bRunOut == true || bChanged == true){
for (int j = i; j <= base.depth(); j++){
relPath += "../";
}
for (int j = i; j <= path.depth(); j++){
relPath += path.directory(j) + "/";
}
break;
}
}
cout << relPath << " ---- " << endl;
return relPath;
}