Example #1
0
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;
}
Example #2
0
/*
    Traverse the hierarchy inside the container
 */
void TskL01Extract::traverse(ewf::libewf_file_entry_t *parent)
{
    static Poco::Path currPath;

    TskL01Extract::ArchivedFile fileInfo;
    fileInfo.entry   = parent;
    fileInfo.type    = getFileType(parent);
    fileInfo.size    = getFileSize(parent);
    fileInfo.ctime   = getEntryChangeTime(parent);
    fileInfo.crtime  = getCreationTime(parent);
    fileInfo.atime   = getAccessTime(parent);
    fileInfo.mtime   = getModifiedTime(parent);
    std::string name = getName(parent);

    bool saveDirectory = false;
    if ((fileInfo.type == 'd') && !name.empty())
    {
        saveDirectory = true;
    }

    if (saveDirectory)
    {
        currPath.pushDirectory(name);
        fileInfo.path = currPath;
        m_archivedFiles.push_back(fileInfo);
    }
    else if (fileInfo.type == 'f')
    {
        Poco::Path tempPath = currPath;
        tempPath.setFileName(name);
        fileInfo.path = tempPath;
        m_archivedFiles.push_back(fileInfo);
    }

    int num = 0;
    ewf::libewf_error_t *ewfError = NULL;
    ewf::libewf_file_entry_get_number_of_sub_file_entries(parent, &num, &ewfError);
    
    if (num > 0)
    {
        //recurse
        for (int i=0; i < num; ++i)
        {
            ewf::libewf_file_entry_t *child = NULL;
            ewfError = NULL;
            if (ewf::libewf_file_entry_get_sub_file_entry(parent, i, &child, &ewfError) == -1)
            {
                throw TskException("TskL01Extract::traverse - Error with libewf_file_entry_get_sub_file_entry: ");
            }

            traverse(child);
        }
    }

    if (saveDirectory)
    {
        currPath.popDirectory();
    }
}
    /**
     * Module initialization function. Optionally receives an output folder
     * path as the location for saving the files corresponding to interesting
     * file set hits. The default output folder path is a folder named for the
     * module in #MODULE_OUT_DIR#.
     *
     * @param args Optional output folder path.
     * @return TskModule::OK if an output folder is created, TskModule::FAIL
     * otherwise. 
     */
    TSK_MODULE_EXPORT TskModule::Status initialize(const char* arguments)
    {
        TskModule::Status status = TskModule::OK;

        const std::string MSG_PREFIX = "SaveInterestingFilesModule::initialize : ";
        try
        {
            Poco::Path outputDirPath;
            if (strlen(arguments) != 0)
            {
                outputDirPath = Poco::Path::forDirectory(arguments);
            }
            else
            {
                outputDirPath = Poco::Path::forDirectory(GetSystemProperty(TskSystemProperties::MODULE_OUT_DIR));
                outputDirPath.pushDirectory(name());
            }
            outputFolderPath = outputDirPath.toString();

            Poco::File(outputDirPath).createDirectory();
        }
        catch (TskException &ex)
        {
            status = TskModule::FAIL;
            outputFolderPath.clear();
            std::stringstream msg;
            msg << MSG_PREFIX << "TskException: " << ex.message();
            LOGERROR(msg.str());
        }
        catch (Poco::Exception &ex)
        {
            status = TskModule::FAIL;
            outputFolderPath.clear();
            std::stringstream msg;
            msg << MSG_PREFIX << "Poco::Exception: " << ex.displayText();
            LOGERROR(msg.str());
        }
        catch (std::exception &ex)
        {
            status = TskModule::FAIL;
            outputFolderPath.clear();
            std::stringstream msg;
            msg << MSG_PREFIX << "std::exception: " << ex.what();
            LOGERROR(msg.str());
        }
        catch (...)
        {
            status = TskModule::FAIL;
            outputFolderPath.clear();
            LOGERROR(MSG_PREFIX + "unrecognized exception");
        }

        return status;
    }
Example #4
0
std::string makeRelativePath(const std::string & sbase, const std::string & spath)
{
	Poco::Path base(sbase);
	Poco::Path path(spath);

	if(base.getNode() != path.getNode()) {
		return spath;
	}
	if(base.getDevice() != path.getDevice()) {
		return spath;
	}

	int baseDepth = base.depth();
	int pathDepth = path.depth();
	if(baseDepth == 0 || pathDepth == 0) {
		return spath;
	}
	
	int i = 0;
	while(base[i] == path[i]) {
		++i;
		if(i == baseDepth || i == pathDepth) {
			break;
		}
	}
	
	if(i == baseDepth && i == pathDepth) {
		return "";
	}

	Poco::Path result;
	for(int k = i; k < baseDepth; ++k) {
		result.pushDirectory("..");
	}
	for(int k = i; k < pathDepth; ++k) {
		result.pushDirectory(path[k]);
	}

	return result.toString();
}
Example #5
0
Poco::Path XplDevice::GetConfigFileLocation() {
    Poco::Path p ( Poco::Path::home() );
    p.pushDirectory ( ".xPL" );
    File test = File(p);
    if (!test.exists()){
        poco_debug ( devLog, "dir doesn't exist:  " + p.toString() );
        test.createDirectory();
    }
    p.pushDirectory ( "xPLSDK_configs" );
    test = File(p);
    if (!test.exists()){
        poco_debug ( devLog, "dir doesn't exist:  " + p.toString() );
        test.createDirectory();
    }
    p.setFileName ( GetCompleteId() + ".conf" );
    test = File(p);
    if (!test.exists()){
        poco_debug ( devLog, "file doesn't exist:  " + p.toString() );
        test.createFile();
    }
    return p;
}
Example #6
0
    /**
     * Module cleanup function. This is where the module should free any resources 
     * allocated during initialization or execution.
     *
     * @returns TskModule::OK on success and TskModule::FAIL on error.
     */
    TskModule::Status TSK_MODULE_EXPORT finalize()
    {
        std::ostringstream msgPrefix;
        msgPrefix << MODULE_NAME << "::finalize : ";
        try
        {
            #if !defined(_DEBUG) 

            // Delete the output folder if it's empty.
            Poco::Path outputFolderPath = Poco::Path::forDirectory(GetSystemProperty(TskSystemProperties::MODULE_OUT_DIR));
            outputFolderPath.pushDirectory(MODULE_NAME);
            Poco::File outputFolder(outputFolderPath);
            std::vector<Poco::File> filesList;
            outputFolder.list(filesList);
            if (filesList.empty())
            {
                outputFolder.remove(true);
            }

            #endif

            return TskModule::OK;
        }
        catch (TskException &ex)
        {
            std::ostringstream msg;
            msg << msgPrefix.str() << "TskException: " << ex.message();
            LOGERROR(msg.str());
            return TskModule::FAIL;
        }
        catch (Poco::Exception &ex)
        {
            std::ostringstream msg;
            msg << msgPrefix.str() << "Poco::Exception: " << ex.displayText();
            LOGERROR(msg.str());
            return TskModule::FAIL;
        }
        catch (std::exception &ex)
        {
            std::ostringstream msg;
            msg << msgPrefix.str() << "std::exception: " << ex.what();
            LOGERROR(msg.str());
            return TskModule::FAIL;
        }
        catch (...)
        {
            LOGERROR(msgPrefix.str() + "unrecognized exception");
            return TskModule::FAIL;
        }
    }
Example #7
0
const std::string OptionsPage::GenerateContent(const std::string &method, const std::map<std::string,QueryVar> &queryvars)
{
	std::string content("");
	std::string sql("");

	if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="save" && ValidateFormPassword(queryvars))
	{
		Option option(m_db);
		option.ClearCache();
		std::vector<std::string> options;
		std::vector<std::string> oldvalues;
		std::vector<std::string> newvalues;
		CreateArgArray(queryvars,"option",options);
		CreateArgArray(queryvars,"oldvalue",oldvalues);
		CreateArgArray(queryvars,"value",newvalues);

		for(int i=0; i<options.size(); i++)
		{
			if(oldvalues[i]!=newvalues[i])
			{

				option.Set(options[i],newvalues[i]);

				// load new language immediately
				if(options[i]=="Language")
				{
					Poco::Path tdir;
					tdir.pushDirectory(global::basepath+"translations");
					tdir=tdir.makeAbsolute();
					tdir.setFileName(newvalues[i]);
					m_trans->LoadLocalizedTranslation(tdir.toString());
				}

				if(options[i]=="MessageDownloadMaxDaysBackward")
				{
					m_db->Execute("INSERT OR IGNORE\
								INTO tblMessageRequests (IdentityID, Day, RequestIndex, Found)\
								SELECT M.IdentityID, M.InsertDate, M.MessageIndex, 'true'\
								FROM tblMessage M\
								LEFT JOIN tblMessageRequests R\
									ON M.IdentityID=R.IdentityID\
									AND M.MessageIndex=R.RequestIndex\
									AND M.InsertDate=R.Day\
								WHERE R.IdentityID IS NULL\
								AND M.IdentityID IS NOT NULL\
								AND M.InsertDate >= date('now',(SELECT -MAX(OptionValue,0) FROM tblOption \
									WHERE Option='MessageDownloadMaxDaysBackward')||' days');");
				}
			}
Example #8
0
/// Loads and registers plugin libraries
bool LoadPlugins (pI::BaseApplication& app) {

    std::string baseDir = app.FindPIBaseDir();

    if (baseDir.empty()) {
        return false;
    }

    Poco::Path pluginDir (baseDir);

#ifdef _DEBUG
    pluginDir.pushDirectory ("DistDebug");
#else
    pluginDir.pushDirectory ("DistRelease");
#endif

    app.LoadPluginLibrary (pluginDir.toString().c_str(), "CImg_pIns");
    app.LoadPluginLibrary (pluginDir.toString().c_str(), "FLLL_pIns");
    app.LoadPluginLibrary (pluginDir.toString().c_str(), "OpenCV_pIns");
    app.LoadPluginLibrary (pluginDir.toString().c_str(), "Freenect_pIns");

    app.RegisterPlugins();
    return true;
}
Example #9
0
//--------------------------------------------------------------
void ofApp::setup(){
    ofSetWindowTitle("LightEchoes Generative Frame Test");
    ofSetFrameRate(60);
    ofSetLogLevel(OF_LOG_VERBOSE);
    ofBackground(50);
    ofSetEscapeQuitsApp(false);
    
    bAutoAdvance = false;
    frame.setup();
    
    frameRate = 60;
    
    Poco::Path path = Poco::Path::home();
    path.pushDirectory("Dropbox");
    path.pushDirectory("LE Shared");
    path.pushDirectory("Frames02");
    outputPath = path.toString();
    ofDirectory::createDirectory(outputPath, false, true);
    
    
    index = 0;
    frame.generate(index);
    incrementAt = ofGetElapsedTimef()+(1/frameRate);
}
Example #10
0
void handleRequests(const string_t& requests) {
    try {
        Poco::Path pp(requests);
        Poco::Path lics = pp.parent().makeDirectory().pushDirectory("licenses");

        Poco::FileInputStream fis(requests);

        while (!fis.eof()) {
            string_t sl;
            string_t sha;
            string_t user;

            std::getline(fis, sl);

            /// check if there is custom mapping file specified current font
            string_t::size_type p = sl.find('|');
            sha = sl.substr(0, p);
            sl = Poco::trim(sl);

            if (p != string_t::npos)
                user = sl.substr(p + 1);

            sha = Poco::trim(sha);
            user = Poco::trim(user);

            if (sha.empty())
                continue;

            Poco::Path tmp = lics;
            tmp.pushDirectory(sha); 
            string_t ss = tmp.toString();

            if ( !Poco::File(ss + LICENSE_FILE).exists() ) {
                SecurityKey sk;
                sk.create(sha, false);

                Poco::File(ss).createDirectories();
                sk.save(ss + LICENSE_FILE);
            }
        }
    }
    catch (const std::exception& e) {
        std::cout << e.what() << std::endl;
    }
    catch (...) {

    }
}
Example #11
0
    /**
     * Module execution function. 
     *
     * @returns TskModule::OK on success, TskModule::FAIL on error, or TskModule::STOP.
     */
    TskModule::Status TSK_MODULE_EXPORT report() 
    {
        std::ostringstream msgPrefix;
        msgPrefix << MODULE_NAME << "::report : ";
        try
        {
            // Create an output folder.
            Poco::Path outputFolderPath = Poco::Path::forDirectory(GetSystemProperty(TskSystemProperties::MODULE_OUT_DIR));
            outputFolderPath.pushDirectory(MODULE_NAME);
            Poco::File(outputFolderPath).createDirectories();

            // Generate the report.
            outputFolderPath.setFileName("SummaryReport.htm");
            TskSummaryReport::generateReport(outputFolderPath.toString());

            return TskModule::OK;
        }
        catch (TskException &ex)
        {
            std::ostringstream msg;
            msg << msgPrefix.str() << "TskException: " << ex.message();
            LOGERROR(msg.str());
            return TskModule::FAIL;
        }
        catch (Poco::Exception &ex)
        {
            std::ostringstream msg;
            msg << msgPrefix.str() << "Poco::Exception: " << ex.displayText();
            LOGERROR(msg.str());
            return TskModule::FAIL;
        }
        catch (std::exception &ex)
        {
            std::ostringstream msg;
            msg << msgPrefix.str() << "std::exception: " << ex.what();
            LOGERROR(msg.str());
            return TskModule::FAIL;
        }
        catch (...)
        {
            LOGERROR(msgPrefix.str() + "unrecognized exception");
            return TskModule::FAIL;
        }
    }
Example #12
0
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;
}