Пример #1
0
void ComputeApp::initialize(Application& self)
{
    Application::initialize(self);

    Poco::Path appPath = commandPath();
    appPath.setExtension("");
    appPath.setFileName("");
    exeDirectory = appPath.toString();

    loadConfiguration();
}
Пример #2
0
    void CPaletteUtil::ExportPalette( const std::string & inparentdirpath, const std::vector<gimg::colorRGB24> & palette )
    {
        Poco::Path inputPal(inparentdirpath);
        Poco::Path outputPath;
        cout <<"Exporting to ";

        if( m_outputPath.empty() )
        {
            outputPath = inputPal.append("palette").makeFile();

            if     (m_outPalType == ePalType::RIFF)   { outputPath.setExtension( utils::io::RIFF_PAL_Filext );           }
            else if(m_outPalType == ePalType::RGBX32) { outputPath.setExtension( pmd2::filetypes::RGBX32_RAW_PAL_FILEX );}
            else if(m_outPalType == ePalType::TEXT)   { outputPath.setExtension( TXTPAL_Filext );                        }
            else
                throw std::runtime_error("ERROR: Invalid output palette type!");
        }
        else
            outputPath = m_outputPath;

        if( m_outPalType == ePalType::RIFF )
        {
            cout<<"RIFF palette \"" <<outputPath.toString() <<"\"\n";
            utils::io::ExportTo_RIFF_Palette( palette, outputPath.toString() );
        }
        else if( m_outPalType == ePalType::RGBX32 )
        {
            cout<<"raw RGBX32 palette\"" <<outputPath.toString() <<"\"\n";
            vector<uint8_t> outdata;
            outdata.reserve( palette.size() * gimg::colorRGB24::getSizeRawBytes() );
            pmd2::graphics::WriteRawPalette_RGB24_As_RGBX32( back_inserter(outdata), palette.begin(), palette.end() );
            utils::io::WriteByteVectorToFile( outputPath.toString(), outdata );
        }
        else if( m_outPalType == ePalType::TEXT )
        {
            cout<<"HTML text palette \"" <<outputPath.toString() <<"\"\n";
            utils::io::ExportTo_TXT_Palette( palette, outputPath.toString() );
        }
    }
Пример #3
0
/**
 * Confirm that an executable file exists at location.
 */
void TskExecutableModule::setPath(const std::string& location)
{
    try
    {
        // Autogenerate filename extension if needed
        Poco::Path tempPath = location;
        if (tempPath.getExtension().empty())
        {
            std::string os = Poco::Environment::osName();
            if (os.find("Windows") != std::string::npos ||
                os.find("CYGWIN")  != std::string::npos ||
                os.find("MINGW")   != std::string::npos )
            {
                tempPath.setExtension("exe");
            }
            // Else we assume the user is on a platform that doesn't use executable extensions.
        }

        // Call our parent to validate the location.
        TskModule::setPath(tempPath.toString());

        m_name = Poco::Path(m_modulePath).getBaseName();

        // Verify that the file is executable.
        Poco::File exeFile(m_modulePath);

        if (!exeFile.canExecute())
        {
            std::wstringstream msg;
            msg << L"TskExecutableModule::setPath - File is not executable: "
                << m_modulePath.c_str();
            LOGERROR(msg.str());
            throw TskException("File is not executable.");
        }
    }
    catch (TskException& tskEx)
    {
        throw tskEx;
    }
    catch(std::exception& ex)
    {
        // Log a message and throw a framework exception.
        std::wstringstream msg;
        msg << "TskExecutableModule::setPath : " << ex.what();
        LOGERROR(msg.str());

        throw TskException("Failed to set location: " + m_modulePath);
    }
}