FileStreamPtr ResourceManager::createFile(const std::string& fileName)
{
    PHYSFS_File* file = PHYSFS_openWrite(fileName.c_str());
    if(!file)
        stdext::throw_exception(stdext::format("failed to create file '%s': %s", fileName, PHYSFS_getLastError()));
    return FileStreamPtr(new FileStream(fileName, file, true));
}
FileStreamPtr ResourceManager::openFile(const std::string& fileName)
{
    std::string fullPath = resolvePath(fileName);
    PHYSFS_File* file = PHYSFS_openRead(fullPath.c_str());
    if(!file)
        stdext::throw_exception(stdext::format("unable to open file '%s': %s", fullPath, PHYSFS_getLastError()));
    return FileStreamPtr(new FileStream(fullPath, file, false));
}
Exemple #3
0
void MyWriter::initialize()
{
    m_stream = FileStreamPtr(FileUtils::createFile(m_filename, true),
                             FileStreamDeleter());
    if (!m_stream)
    {
        std::stringstream out;
        out << "writers.mywriter couldn't open '" << m_filename <<
            "' for output.";
        throw pdal_error(out.str());
    }
}
Exemple #4
0
void MyWriter::processOptions(const Options& options)
{
    m_filename = options.getValueOrThrow<std::string>("filename");
    m_stream = FileStreamPtr(FileUtils::createFile(m_filename, true),
                             FileStreamDeleter());
    if (!m_stream)
    {
        std::stringstream out;
        out << "writers.mywriter couldn't open '" << m_filename <<
            "' for output.";
        throw pdal_error(out.str());
    }

    m_newline = options.getValueOrDefault<std::string>("newline", "\n");
    m_datafield = options.getValueOrDefault<std::string>("datafield", "UserData");
    m_precision = options.getValueOrDefault<int>("precision", 3);
}