本文整理汇总了C++中poco::Path类的典型用法代码示例。如果您正苦于以下问题:C++ Path类的具体用法?C++ Path怎么用?C++ Path使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Path类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDataPath
bool WorkbenchPlugin::GetDataPath(Poco::Path& path)
{
QFileInfo fileInfo = bundleContext->getDataFile("");
path.assign(fileInfo.absolutePath().toStdString() + '/');
return fileInfo.isWritable();
}
示例2:
void
BundleLoader::InstallLibraries(IBundle::Pointer bundle, bool copy)
{
std::vector<std::string> libraries;
this->ListLibraries(bundle, libraries);
std::vector<std::string>::iterator iter;
for (iter = libraries.begin(); iter != libraries.end(); ++iter)
{
if (iter->empty()) continue;
//BERRY_INFO << "Testing CodeCache for: " << *iter << std::endl;
std::size_t separator = iter->find_last_of("/");
std::string libFileName = *iter;
if (separator != std::string::npos)
libFileName = iter->substr(separator+1);
if (!m_CodeCache->HasLibrary(libFileName))
{
std::string libDir = "";
if (separator != std::string::npos)
libDir += iter->substr(0, separator);
// Check if we should copy the dll (from a ZIP file for example)
if (copy)
{
//TODO This copies all files which start with *iter to the
// plugin cache. This is necessary for Windows, for example,
// where a .dll file is accompanied by a set of other files.
// This should be extended to check for the right dll files, since
// it would be possible (and a good idea anyway) to put multiple
// versions of the same library in the ZIP file, targeting different
// compilers for example.
std::vector<std::string> files;
bundle->GetStorage().List(libDir, files);
for (std::vector<std::string>::iterator fileName = files.begin();
fileName != files.end(); ++fileName)
{
std::size_t size = std::min<std::size_t>(libFileName.size(), fileName->size());
if (fileName->compare(0, size, libFileName) != 0) continue;
std::istream* istr = bundle->GetResource(libDir + *fileName);
m_CodeCache->InstallLibrary(*iter, *istr);
delete istr;
}
}
else
{
Poco::Path bundlePath = bundle->GetStorage().GetPath();
bundlePath.append(Poco::Path::forDirectory(libDir));
// On Windows, we set the path environment variable to include
// the path to the library, so the loader can find it. We do this
// programmatically because otherwise, a user would have to edit
// a batch file every time he adds a new plugin from outside the
// build system.
#ifdef BERRY_OS_FAMILY_WINDOWS
std::string pathEnv = Poco::Environment::get("PATH", "");
if (!pathEnv.empty()) pathEnv += ";";
pathEnv += bundlePath.toString();
Poco::Environment::set("PATH", pathEnv);
#endif
m_CodeCache->InstallLibrary(libFileName, bundlePath);
}
}
}
}
示例3: handleRequest
void FileSystemRouteHandler::handleRequest(Poco::Net::HTTPServerRequest& request,
Poco::Net::HTTPServerResponse& response)
{
Poco::Path dataFolder(ofToDataPath("",true));
Poco::Path documentRoot(ofToDataPath(_parent.getSettings().getDocumentRoot(),true));
std::string dataFolderString = dataFolder.toString();
std::string documentRootString = documentRoot.toString();
// doc root validity check
if(_parent.getSettings().getRequireDocumentRootInDataFolder() &&
(documentRootString.length() < dataFolderString.length() ||
documentRootString.substr(0,dataFolderString.length()) != dataFolderString))
{
ofLogError("ServerDefaultRouteHandler::handleRequest") << "Document Root is not a sub directory of the data folder.";
response.setStatusAndReason(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR);
_parent.handleRequest(request,response);
return;
}
// check path
Poco::URI uri(request.getURI());
std::string path = uri.getPath(); // just get the path
// make paths absolute
if(path.empty())
{
path = "/";
}
Poco::Path requestPath = documentRoot.append(path).makeAbsolute();
// add the default index if no filename is requested
if(requestPath.getFileName().empty())
{
requestPath.append(_parent.getSettings().getDefaultIndex()).makeAbsolute();
}
std::string requestPathString = requestPath.toString();
// double check path safety (not needed?)
if((requestPathString.length() < documentRootString.length() ||
requestPathString.substr(0,documentRootString.length()) != documentRootString))
{
ofLogError("ServerDefaultRouteHandler::handleRequest") << "Requested document not inside DocumentFolder.";
response.setStatusAndReason(Poco::Net::HTTPResponse::HTTP_NOT_FOUND);
_parent.handleRequest(request,response);
return;
}
ofFile file(requestPathString); // use it to parse file name parts
try
{
// ofx::Media::MediaTypeMap mediaMap;
// Poco::Net::MediaType mediaType = mediaMap.getMediaTypeForSuffix(file.getExtension());
std::string mediaTypeString = "application/octet-stream";
std::string ext = file.getExtension();
if(ext == "json")
{
mediaTypeString = "application/json";
}
else if(ext == "html")
{
mediaTypeString = "text/html";
}
else if(ext == "jpg" || ext == "jpeg")
{
mediaTypeString = "image/jpeg";
}
else if(ext == "png")
{
mediaTypeString = "image/png";
}
else if(ext == "js")
{
mediaTypeString = "application/javascript";
}
else if(ext == "css")
{
mediaTypeString = "text/css";
}
else if(ext == "xml")
{
mediaTypeString = "application/xml";
}
else if(ext == "ico")
{
mediaTypeString = "image/x-icon";
}
response.sendFile(file.getAbsolutePath(), mediaTypeString); // will throw exceptions
return;
}
catch (const Poco::FileNotFoundException& ex)
{
//.........这里部分代码省略.........
示例4: mui_init
void mui_init(){
#if TARGET_OS_IPHONE
if( mui::MuiConfig::detectRetina ){
ofAppiOSWindow * w = ofAppiOSWindow::getInstance();
if( w->isRetinaEnabled() ){
mui::MuiConfig::scaleFactor = 2;
mui::MuiConfig::useRetinaAssets = true;
}
}
#endif
//TODO: allow retina in osx too!
Poco::Path appPath;
#if TARGET_OS_IPHONE
// http://www.cocoabuilder.com/archive/cocoa/193451-finding-out-executable-location-from-c-program.html
CFBundleRef bundle = CFBundleGetMainBundle();
CFURLRef url = CFBundleCopyExecutableURL(bundle); // CFBundleCopyResourcesDirectoryURL(bundle);
CFURLRef absolute = CFURLCopyAbsoluteURL(url);
CFStringRef path = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
CFIndex maxLength = CFStringGetMaximumSizeOfFileSystemRepresentation(path);
char *result = (char*)malloc(maxLength);
if(result) {
if(!CFStringGetFileSystemRepresentation(path,result, maxLength)) {
free(result);
result = NULL;
}
}
CFRelease(path);
CFRelease(url);
CFRelease(absolute);
appPath = Poco::Path(result);
appPath = appPath.parent();
#elif TARGET_OS_MAC
// http://www.cocoabuilder.com/archive/cocoa/193451-finding-out-executable-location-from-c-program.html
CFBundleRef bundle = CFBundleGetMainBundle();
CFURLRef url = CFBundleCopyExecutableURL(bundle); // CFBundleCopyResourcesDirectoryURL(bundle);
CFURLRef absolute = CFURLCopyAbsoluteURL(url);
CFStringRef path = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
CFIndex maxLength = CFStringGetMaximumSizeOfFileSystemRepresentation(path);
char *result = (char*)malloc(maxLength);
if(result) {
if(!CFStringGetFileSystemRepresentation(path,result, maxLength)) {
free(result);
result = NULL;
}
}
CFRelease(path);
CFRelease(url);
CFRelease(absolute);
appPath = Poco::Path(result);
appPath = appPath.parent().parent().pushDirectory("Resources");
if( mui::MuiConfig::detectRetina ){
ofAppGLFWWindow * window = dynamic_cast<ofAppGLFWWindow*>(ofGetWindowPtr());
if( window != NULL ){
mui::MuiConfig::scaleFactor = window->getPixelScreenCoordScale();
}
}
#else
appPath = Poco::Path(ofToDataPath("", true));
#endif
mui::MuiConfig::dataPath = appPath.absolute();
}
示例5: main
int main(int argc, char *argv[]) {
std::string BuildVer(BUILD_VERSION);
cout<<"FastCraft Minecraft Server"<<"\n";
cout<<"Version "<<BUILD_VERSION<<(BuildVer.compare("") == 0 ? "" : "-")<<FC_VERSION<<" for Minecraft "<<FC_SUPPORTED_MINCRAFTVERSION<<"\n"<<std::endl;
Poco::Path pathRoot(argv[0]);
pathRoot.setFileName(""); //Remove filename
pathRoot.pushDirectory("Server");
Poco::File fileRootDirectory(pathRoot.toString());
if (!fileRootDirectory.exists()) {
try {
fileRootDirectory.createDirectories();
}catch(Poco::FileException& ex) {
cout<<"Unable to create server directory ("<<ex.message()<<")"<<std::endl;
}
}else{
if ((!fileRootDirectory.canRead()) || (!fileRootDirectory.canWrite())) {
cout<<"Unable to read or write FastCraft root directory"<<std::endl;
Thread::sleep(3000);
return 0;
}
}
std::vector<MinecraftServer*> vpServer(0);
std::vector<Poco::File> vFileList(0);
fileRootDirectory.list(vFileList);
if (vFileList.empty()) {
cout<<"No server configurations found!"<<std::endl;
Thread::sleep(3000);
return 0;
}
Poco::Data::SQLite::Connector::registerConnector(); //Startup sqlite engine
Constants::init(); //load constants
MinecraftServer* pServer;
Poco::Path pathTemp;
int x;
//Start all server
for (x=0;x<=vFileList.size()-1;x++) {
if (!vFileList[x].isDirectory()) {continue;} //Skip files
if(!pathTemp.tryParse(vFileList[x].path())) {
cout<<"Illegal path!"<<std::endl;
Thread::sleep(3000);
return 0;
}
try {
cout<<"Starting "<<pathTemp[pathTemp.depth()]<<"\n";
pathTemp.pushDirectory(pathTemp[pathTemp.depth()]);
pathTemp.setFileName("");
pServer = new MinecraftServer(pathTemp[pathTemp.depth()-1],pathTemp);
}catch(Poco::RuntimeException& ex) {
cout<<"Unable to start server ("<<ex.message()<<")"<<std::endl;
Thread::sleep(3000);
return 0;
}
vpServer.push_back(pServer);
pathTemp.clear();
}
cout<<"Loading done!\n";
bool fSomethingRuns = false;
while(1) {
Thread::sleep(1000);
//Check if there is at least one server that runs
fSomethingRuns=false;
for (x=0;x<=vpServer.size()-1;x++) {
if (vpServer[x]->isRunning()) {
fSomethingRuns=true;
break;
}
}
if (!fSomethingRuns) {break;}
}
Poco::Data::SQLite::Connector::unregisterConnector();
return 1;
}
示例6: RestoreState
void DebugBreakpointManager::RestoreState(const Poco::Path& path)
{
try
{
Poco::XML::DOMParser parser;
Poco::FileInputStream reader(path.toString());
Poco::XML::InputSource source(reader);
//source.setSystemId(baseDir);
Poco::XML::Document* doc = parser.parse(&source);
Poco::XML::Element* breakpoints = doc->documentElement();
if (breakpoints)
{
// restore object breakpoints
Poco::XML::NodeList* elementList = breakpoints->getElementsByTagName(
OBJECT_TAG);
for (std::size_t i = 0; i < elementList->length(); i++)
{
Poco::XML::Element* elem =
dynamic_cast<Poco::XML::Element*> (elementList->item(i));
if (!elem->hasAttribute(ID_ATTR))
continue;
const std::string& attr = elem->getAttribute(ID_ATTR);
int traceId = 0;
try
{
traceId = Poco::NumberParser::parse(attr);
} catch (const Poco::SyntaxException& e)
{
BERRY_WARN << e.displayText();
}
DebugUtil::GetBreakpointManager()->AddObjectBreakpoint(traceId);
}
elementList->release();
// restore smartpointer breakpoints
elementList = breakpoints->getElementsByTagName(SMARTPOINTER_TAG);
for (std::size_t i = 0; i < elementList->length(); i++)
{
Poco::XML::Element* elem =
dynamic_cast<Poco::XML::Element*> (elementList->item(i));
if (!elem->hasAttribute(ID_ATTR))
continue;
const std::string& attr = elem->getAttribute(ID_ATTR);
int spId = 0;
try
{
spId = Poco::NumberParser::parse(attr);
} catch (const Poco::SyntaxException& e)
{
BERRY_WARN << e.displayText();
}
DebugUtil::GetBreakpointManager()->AddSmartpointerBreakpoint(spId);
}
elementList->release();
}
doc->release();
} catch (Poco::XML::SAXParseException& e)
{
BERRY_WARN << e.displayText();
}
catch (Poco::FileNotFoundException& /*e*/)
{
}
catch (Poco::FileException& e)
{
BERRY_WARN << e.displayText();
}
}
示例7: getCurrentWorkingDirectory
string getCurrentWorkingDirectory() {
Poco::Path p;
return p.current();
}
示例8: handleRequest
void FileSystemRoute::handleRequest(ServerEventArgs& evt)
{
Poco::Path dataFolder(ofToDataPath("", true));
Poco::Path documentRoot(ofToDataPath(getSettings().getDocumentRoot(), true));
std::string dataFolderString = dataFolder.toString();
std::string documentRootString = documentRoot.toString();
// Document root validity check.
if (_settings.getRequireDocumentRootInDataFolder() &&
(documentRootString.length() < dataFolderString.length() ||
documentRootString.substr(0, dataFolderString.length()) != dataFolderString))
{
ofLogError("FileSystemRoute::handleRequest") << "Document Root is not a sub directory of the data folder.";
evt.getResponse() .setStatusAndReason(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR);
handleErrorResponse(evt);
return;
}
// check path
Poco::URI uri(evt.getRequest().getURI());
std::string path = uri.getPath(); // just get the path
// make paths absolute
if (path.empty())
{
path = "/";
}
Poco::Path requestPath = documentRoot.append(path).makeAbsolute();
// add the default index if no filename is requested
if (requestPath.getFileName().empty())
{
requestPath.append(getSettings().getDefaultIndex()).makeAbsolute();
}
std::string requestPathString = requestPath.toString();
// double check path safety (not needed?)
if ((requestPathString.length() < documentRootString.length() ||
requestPathString.substr(0, documentRootString.length()) != documentRootString))
{
ofLogError("FileSystemRoute::handleRequest") << "Requested document not inside DocumentFolder.";
evt.getResponse().setStatusAndReason(Poco::Net::HTTPResponse::HTTP_NOT_FOUND);
handleErrorResponse(evt);
return;
}
ofFile file(requestPathString); // use it to parse file name parts
std::string mediaTypeString = MediaTypeMap::getDefault()->getMediaTypeForPath(file.path()).toString();
try
{
// TODO: this is where we would begin to work honoring
/// Accept-Encoding:gzip, deflate, sdch
evt.getResponse().sendFile(file.getAbsolutePath(), mediaTypeString);
return;
}
catch (const Poco::FileNotFoundException& exc)
{
ofLogError("FileSystemRoute::handleRequest") << exc.displayText();
evt.getResponse().setStatusAndReason(Poco::Net::HTTPResponse::HTTP_NOT_FOUND);
handleErrorResponse(evt);
return;
}
catch (const Poco::OpenFileException& exc)
{
ofLogError("FileSystemRoute::handleRequest") << exc.displayText();
evt.getResponse().setStatusAndReason(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR);
handleErrorResponse(evt);
return;
}
catch (const std::exception& exc)
{
ofLogError("FileSystemRoute::handleRequest") << "Unknown server error: " << exc.what();
evt.getResponse().setStatusAndReason(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR);
handleErrorResponse(evt);
return;
}
}
示例9: file
Poco::Net::MediaType MediaTypeMap::getMediaTypeForPath(const Poco::Path& path) const
{
Poco::File file(path);
if (file.exists() && file.isDirectory())
{
return Poco::Net::MediaType("inode/directory");
}
else
{
FileExtensionConstIterator iter = _fileExtensionToMediaTypeMap.find(Poco::UTF8::toLower(path.getExtension()));
if (iter != _fileExtensionToMediaTypeMap.end())
{
return (*iter).second;
}
else
{
return _defaultMediaType;
}
}
}
示例10: getTestFile
std::string ZipTest::getTestFile(const std::string& testFile)
{
Poco::Path root;
root.makeAbsolute();
Poco::Path result;
while (!Poco::Path::find(root.toString(), "data", result))
{
root.makeParent();
if (root.toString().empty() || root.toString() == "/")
throw Poco::FileNotFoundException("Didn't find data subdir");
}
result.makeDirectory();
result.setFileName(testFile);
Poco::File aFile(result.toString());
if (!aFile.exists() || (aFile.exists() && !aFile.isFile()))
throw Poco::FileNotFoundException("Didn't find " + testFile);
return result.toString();
}
示例11: LoadConfig
void XplDevice::LoadConfig()
{
poco_trace ( devLog, "loading config for " + GetCompleteId() );
Poco::Path p = GetConfigFileLocation();
PropertyFileConfiguration* cfgp;
try{
cfgp = new PropertyFileConfiguration(p.toString());
} catch (Poco::FileException e) {
poco_debug ( devLog, "Failed to parse " + p.toString() );
cfgp = (new PropertyFileConfiguration());
}
m_configStore = cfgp;
m_bConfigRequired = true;
AbstractConfiguration::Keys itemKeys;
m_configStore->keys(itemKeys);
for ( AbstractConfiguration::Keys::iterator iter = itemKeys.begin(); iter != itemKeys.end(); ++iter )
{
poco_debug ( devLog, " item: " + *iter );
}
if ( m_configStore->hasProperty ( "instanceId" ) )
{
//looks like we really have a config
poco_debug ( devLog, "found instance ID" );
m_bConfigRequired = false;
SetInstanceId ( m_configStore->getString ( "instanceId" ) );
if ( m_configStore->hasProperty ( "configItems" )) {
AbstractConfiguration::Keys confItemKeys;
m_configStore->keys("configItems", confItemKeys);
poco_debug ( devLog, "found " + NumberFormatter::format(confItemKeys.size()) + "keys" );
for ( AbstractConfiguration::Keys::iterator iter = confItemKeys.begin(); iter != confItemKeys.end(); ++iter )
{
if(m_configStore->hasProperty ( "configItems."+(*iter)+".numValues" )){
// we have a config item entry with the required parts, but should only restore it if it matches a programatically-added configitem.
AutoPtr<XplConfigItem> cfgItem = GetConfigItem(*iter);
if (cfgItem.get()== NULL){
poco_warning ( devLog, "Found a config item for name " + *iter + ", but no programatically-created config item exists with that name" );
continue;
}
poco_trace ( devLog, "Config item: " + *iter );
int numValues = m_configStore->getInt ( "configItems."+(*iter)+".numValues");
for (int i= 0; i<numValues; i++) {
poco_trace( devLog, "Value " );
string valname = "configItems."+(*iter)+".value" + NumberFormatter::format(i);
if(m_configStore->hasProperty (valname) ){
cfgItem->AddValue(m_configStore->getString ( valname ));
}
}
}
}
}
}
// // If the config data was read ok, then configure this device.
if( !m_bConfigRequired )
{
// Configure the XplDevice
Configure();
m_bConfigRequired = false;
// Set the config event
//SetEvent( m_hConfig );
// m_hConfig.notifyAsync(NULL, m_hConfig);
}
}
示例12: fileexists
bool fileexists(const Poco::Path& name)
{
struct stat buffer;
return (stat (name.toString().c_str(), &buffer) == 0);
}
示例13: updateServer
void ofxRemoteUIServer::updateServer(float dt){
timeCounter += dt;
broadcastTime += dt;
timeSinceLastReply += dt;
if(readyToSend){
if (timeCounter > updateInterval){
timeCounter = 0.0f;
//vector<string> changes = scanForUpdatedParamsAndSync(); //sends changed params to client
//cout << "ofxRemoteUIServer: sent " << ofToString(changes.size()) << " updates to client" << endl;
//sendUpdateForParamsInList(changes);
}
}
//let everyone know I exist and which is my port, every now and then
if(broadcastTime > OFXREMOTEUI_BORADCAST_INTERVAL){
if(doBroadcast){
broadcastTime = 0.0f;
if (computerName.size() == 0){
#ifdef OF_AVAILABLE
Poco::Environment e;
computerName = e.nodeName();
char pathbuf[2048];
uint32_t bufsize = sizeof(pathbuf);
#ifdef TARGET_OSX
_NSGetExecutablePath(pathbuf, &bufsize);
Poco::Path p = Poco::Path(pathbuf);
binaryName = p[p.depth()];
#endif
#ifdef TARGET_WIN32
GetModuleFileNameA( NULL, pathbuf, bufsize ); //no iea why, but GetModuleFileName() is not defined?
Poco::Path p = Poco::Path(pathbuf);
binaryName = p[p.depth()];
#endif
#endif
}
ofxOscMessage m;
m.addIntArg(port); //0
m.addStringArg(computerName); //1
m.addStringArg(binaryName); //2
broadcastSender.sendMessage(m);
}
}
while( oscReceiver.hasWaitingMessages() ){// check for waiting messages from client
ofxOscMessage m;
oscReceiver.getNextMessage(&m);
if (!readyToSend){ // if not connected, connect to our friend so we can talk back
connect(m.getRemoteIp(), port + 1);
}
DecodedMessage dm = decode(m);
RemoteUIServerCallBackArg cbArg; // to notify our "delegate"
cbArg.host = m.getRemoteIp();
switch (dm.action) {
case HELO_ACTION: //if client says hi, say hi back
sendHELLO();
if(callBack != NULL){
cbArg.action = CLIENT_CONNECTED;
callBack(cbArg);
}
if(verbose_) cout << "ofxRemoteUIServer: " << m.getRemoteIp() << " says HELLO!" << endl;
onScreenNotifications.addNotification("CONNECTED (" + cbArg.host + ")!");
break;
case REQUEST_ACTION:{ //send all params to client
if(verbose_) cout << "ofxRemoteUIServer: " << m.getRemoteIp() << " sends REQU!" << endl;
vector<string>paramsList = getAllParamNamesList();
syncAllParamsToPointers();
sendUpdateForParamsInList(paramsList);
sendREQU(true); //once all send, confirm to close the REQU
}
break;
case SEND_PARAM_ACTION:{ //client is sending us an updated val
if(verbose_) cout << "ofxRemoteUIServer: " << m.getRemoteIp() << " sends SEND!" << endl;
updateParamFromDecodedMessage(m, dm);
if(callBack != NULL){
cbArg.action = CLIENT_UPDATED_PARAM;
cbArg.paramName = dm.paramName;
cbArg.param = params[dm.paramName]; //copy the updated param to the callbakc arg
callBack(cbArg);
}
}
break;
case CIAO_ACTION:{
if(verbose_) cout << "ofxRemoteUIServer: " << m.getRemoteIp() << " says CIAO!" << endl;
sendCIAO();
onScreenNotifications.addNotification("DISCONNECTED (" + cbArg.host + ")!");
if(callBack != NULL){
cbArg.action = CLIENT_DISCONNECTED;
callBack(cbArg);
}
clearOscReceiverMsgQueue();
readyToSend = false;
//.........这里部分代码省略.........
示例14: TskException
/*
* If containerFile is NULL, then we don't use that as a source for paths and we set the parent ID to 0.
*/
int TskL01Extract::extractFiles(TskFile * containerFile /*= NULL*/)
{
static const std::string MSG_PREFIX = "TskL01Extract::extractFiles : ";
try
{
m_containerFile = containerFile;
if (m_archivePath.empty())
{
throw TskException(MSG_PREFIX + "No path to archive provided.");
}
std::string L01Path = TskUtilities::toUTF8(m_archivePath);
if (m_containerFile != NULL)
{
L01Path = m_containerFile->getPath();
}
//m_db.addImageInfo((int)m_img_info->itype, m_img_info->sector_size);
m_db.addImageName(L01Path.c_str());
if (openContainer() != 0)
{
return -1;
}
if (m_imgInfo == NULL)
{
throw TskException(MSG_PREFIX +"Images not open yet");
}
// Create a map of directory names to file ids to use to
// associate files/directories with the correct parent.
std::map<std::string, uint64_t> directoryMap;
std::vector<ArchivedFile>::iterator it = m_archivedFiles.begin();
for (; it != m_archivedFiles.end(); ++it)
{
Poco::Path path(it->path);
Poco::Path parent = it->path.parent();
std::string name;
if (path.isDirectory())
{
name = path[path.depth() - 1];
}
else
{
name = path[path.depth()];
}
// Determine the parent id of the file.
uint64_t parentId = 0;
if (path.depth() == 0 || path.isDirectory() && path.depth() == 1)
{
// This file or directory lives at the root so our parent id
// is the containing file id (if a containing file was provided).
if (m_containerFile != NULL)
{
parentId = m_containerFile->getId();
}
}
else
{
// We are not at the root so we need to lookup the id of our
// parent directory.
std::map<std::string, uint64_t>::const_iterator pos;
pos = directoryMap.find(parent.toString());
if (pos == directoryMap.end())
{
//error!
std::stringstream msg;
msg << "extractFiles: parent ID not mapped for " << it->path.toString();
LOGERROR(msg.str());
}
else
{
parentId = pos->second;
}
}
// Store some extra details about the derived (i.e, extracted) file.
std::stringstream details; ///@todo anything here?
std::string fullpath = "";
if (m_containerFile != NULL)
{
fullpath.append(m_containerFile->getFullPath());
}
fullpath.append("\\");
fullpath.append(path.toString());
uint64_t fileId;
if (m_db.addDerivedFileInfo(name,
parentId,
//.........这里部分代码省略.........
示例15: removeFile
inline
void removeFile(const Poco::Path& path, const bool recursive = false)
{
removeFile(path.toString(), recursive);
}