Пример #1
0
void MaterialItem::slot_export()
{
    const char* project_path = m_editor_context.m_project.get_path();
    const filesystem::path project_root_path = filesystem::path(project_path).parent_path();
    const filesystem::path file_path = absolute("material.dmt", project_root_path);
    const filesystem::path file_root_path = file_path.parent_path();

    QString filepath =
        get_save_filename(
            0,
            "Export...",
            "Disney Materials (*.dmt)",
            m_editor_context.m_settings,
            SETTINGS_FILE_DIALOG_PROJECTS);

    if (!filepath.isEmpty())
    {
        if (QFileInfo(filepath).suffix().isEmpty())
            filepath += ".dmt";

        filepath = QDir::toNativeSeparators(filepath);

        ParamArray parameters = m_entity->get_parameters();
        parameters.insert("__name", m_entity->get_name());
        parameters.insert("__model", m_entity->get_model());

        SettingsFileWriter writer;
        if (!writer.write(filepath.toStdString().c_str(), parameters))
        {
            show_error_message_box(
                "Exporting Error",
                "Failed to export the Disney Material file " + filepath.toStdString() + ".");
        }
    }
}
Пример #2
0
void MainWindow::slot_save_project_as()
{
    assert(m_project_manager.is_project_open());

    QFileDialog::Options options;
    QString selected_filter;

    QString filepath =
        QFileDialog::getSaveFileName(
            this,
            "Save As...",
            m_settings.get_path_optional<QString>(LAST_DIRECTORY_SETTINGS_KEY),
            "Project Files (*.appleseed)",
            &selected_filter,
            options);

    if (!filepath.isEmpty())
    {
        filepath = QDir::toNativeSeparators(filepath);

        const filesystem::path path(filepath.toStdString());

        m_settings.insert_path(
            LAST_DIRECTORY_SETTINGS_KEY,
            path.parent_path().string());

        m_project_manager.save_project_as(filepath.toAscii().constData());

        update_recent_files_menu(filepath);
        update_workspace();
    }
}
Пример #3
0
	static std::wstring s_abs_path(const filesystem::path& file)
	{
		if (!file.is_absolute())
			return (s_path / file).wstring();
		else
			return file.wstring();
	}
Пример #4
0
void BenchmarkRunnerThread::run()
{
    auto_release_ptr<XMLFileBenchmarkListener> xmlfile_listener(
        create_xmlfile_benchmark_listener());

    const string xmlfile_name = "benchmark." + get_time_stamp_string() + ".xml";
    const filesystem::path xmlfile_path =
          filesystem::path(Application::get_tests_root_path())
        / "unit benchmarks"
        / "results"
        / xmlfile_name;

    if (!xmlfile_listener->open(xmlfile_path.string().c_str()))
    {
        emit signal_cannot_create_benchmark_file();
        return;
    }

    BenchmarkResult result;
    result.add_listener(xmlfile_listener.get());

    const filesystem::path old_current_path =
        Application::change_current_directory_to_tests_root_path();

    BenchmarkSuiteRepository::instance().run(result);

    filesystem::current_path(old_current_path);

    emit signal_finished();
}
void GenericMeshFileReader::read(IMeshBuilder& builder)
{
    const filesystem::path filepath(impl->m_filename);
    const string extension = lower_case(filepath.extension().string());

    if (extension == ".obj")
    {
        OBJMeshFileReader reader(impl->m_filename, impl->m_obj_options);
        reader.read(builder);
    }
    else if (extension == ".abc")
    {
        AlembicMeshFileReader reader(impl->m_filename);
        reader.read(builder);
    }
    else if (extension == ".binarymesh")
    {
        BinaryMeshFileReader reader(impl->m_filename);
        reader.read(builder);
    }
    else
    {
        throw ExceptionUnsupportedFileFormat(impl->m_filename.c_str());
    }
}
Пример #6
0
void TextureCollectionItem::slot_import_textures()
{
    QFileDialog::Options options;
    QString selected_filter;

    const QStringList filepaths =
        QFileDialog::getOpenFileNames(
            treeWidget(),
            "Import Textures...",
            m_settings.get_path_optional<QString>(LAST_DIRECTORY_SETTINGS_KEY),
            "Texture Files (*.exr);;All Files (*.*)",
            &selected_filter,
            options);

    if (filepaths.empty())
        return;

    const filesystem::path path(
        QDir::toNativeSeparators(filepaths.first()).toStdString());

    m_settings.insert_path(
        LAST_DIRECTORY_SETTINGS_KEY,
        path.parent_path().string());

    for (int i = 0; i < filepaths.size(); ++i)
    {
        const string filepath = QDir::toNativeSeparators(filepaths[i]).toStdString();
        m_project_builder.insert_texture(m_parent, m_parent_item, filepath);
    }
}
Пример #7
0
        std::string GetFilenameWithoutExtension(const filesystem::path& filePath)
        {
            auto extension = filePath.extension();
            auto filename = filePath.filename();

            return !extension.empty() ? filename.substr(0, filename.length() - extension.length() - 1) : filename;
        }
Пример #8
0
int main(int argc, const char* argv[])
{
    SuperLogger logger;

    Application::check_installation(logger);

    CommandLineHandler cl;
    cl.parse(argc, argv, logger);

    global_logger().add_target(&logger.get_log_target());

    // Construct the schema filename.
    const filesystem::path schema_path =
          filesystem::path(Application::get_root_path())
        / "schemas/project.xsd";

    // Load the input project from disk.
    ProjectFileReader reader;
    auto_release_ptr<Project> project(
        reader.read(
            cl.m_filename.values()[0].c_str(),
            schema_path.file_string().c_str()));

    // Bail out if the project couldn't be loaded.
    if (project.get() == 0)
        return 1;

    // Write the project back to disk.
    return ProjectFileWriter::write(project.ref()) ? 0 : 1;
}
Пример #9
0
string Utils::osPath(const filesystem::path &path)
{
#ifdef __WIN32__
	return nowide::narrow(path.generic_wstring());
#else
	return path.generic_string();
#endif
}
void RenderingManager::archive_frame_to_disk()
{
    RENDERER_LOG_INFO("archiving frame to disk...");

    const filesystem::path autosave_path =
          filesystem::path(Application::get_root_path())
        / "images" / "autosave";

    m_project->get_frame()->archive(autosave_path.string().c_str());
}
Пример #11
0
void BenchmarkWindow::reload_benchmarks()
{
    const filesystem::path benchmarks_path =
          filesystem::path(Application::get_tests_root_path())
        / "unit benchmarks/results/";

    m_benchmark_aggregator.clear();
    m_benchmark_aggregator.scan_directory(benchmarks_path.string().c_str());

    populate_benchmarks_treeview();
}
Пример #12
0
void makePathCompact(const filesystem::path& path, filesystem::path& out_compact)
{
    out_compact.clear();
        
    for(filesystem::path::const_iterator p = path.begin(); p != path.end(); ++p){
        if(*p == ".."){
            out_compact = out_compact.parent_path();
        } else if(*p != "."){
            out_compact /= *p;
        }
    }
}
Пример #13
0
void
Dispatcher::Did_LocalFile_AddOrModify_Execute(filesystem::path relativeFilePath)
{
  _LOG_DEBUG(m_localUserName << " calls LocalFile_AddOrModify_Execute");
  filesystem::path absolutePath = m_rootDir / relativeFilePath;
  if (!filesystem::exists(absolutePath)) {
    //BOOST_THROW_EXCEPTION (Error::Dispatcher() << error_info_str("Update non exist file: " + absolutePath.string() ));
    _LOG_DEBUG("Update non exist file: " << absolutePath.string());
    return;
  }

  FileItemPtr currentFile = m_fileState->LookupFile(relativeFilePath.generic_string());
  if (currentFile &&
      *Hash::FromFileContent(absolutePath) ==
        Hash(currentFile->file_hash().c_str(), currentFile->file_hash().size())
      // The following two are commented out to prevent front end from reporting intermediate files
      // should enable it if there is other way to prevent this
      // && last_write_time (absolutePath) == currentFile->mtime ()
      // && status (absolutePath).permissions () == static_cast<filesystem::perms> (currentFile->mode ())
      ) {
    _LOG_ERROR("Got notification about the same file [" << relativeFilePath << "]");
    return;
  }

  if (currentFile && !currentFile->is_complete()) {
    _LOG_ERROR("Got notification about incomplete file [" << relativeFilePath << "]");
    return;
  }


  int seg_num;
  HashPtr hash;
  tie(hash, seg_num) = m_objectManager.localFileToObjects(absolutePath, m_localUserName);

  try {
    m_actionLog->AddLocalActionUpdate(relativeFilePath.generic_string(),
                                      *hash,
                                      last_write_time(absolutePath),
#if BOOST_VERSION >= 104900
                                      status(absolutePath).permissions(),
#else
                                      0,
#endif
                                      seg_num);

    // notify SyncCore to propagate the change
    m_core->localStateChangedDelayed();
  }
  catch (filesystem::filesystem_error& error) {
    _LOG_ERROR("File operations failed on [" << relativeFilePath << "] (ignoring)");
  }
}
Пример #14
0
void Renderer::setupEmptyDirectory(const filesystem::path &path) {
    FileUtils::createDir(path.str());
    tinydir_dir dir;
    tinydir_open_sorted(&dir, path.str().c_str());
    for (size_t i = 0; i < dir.n_files; ++i) {
        tinydir_file file;
        tinydir_readfile_n(&dir, &file, i);
        if (file.is_reg) {
            FileUtils::deleteFile((path / file.name).str());
        }
    }
    tinydir_close(&dir);
}
Пример #15
0
int main(int argc, const char* argv[])
{
    SuperLogger logger;
    Application::check_installation(logger);

    CommandLineHandler cl;
    cl.parse(argc, argv, logger);

    // Initialize the renderer's logger.
    global_logger().add_target(&logger.get_log_target());

    // Retrieve the input file path.
    const string& input_filepath = cl.m_filename.value();

    // Construct the schema file path.
    const filesystem::path schema_filepath =
          filesystem::path(Application::get_root_path())
        / "schemas"
        / "project.xsd";

    // Read the input project from disk.
    // Note: it is crucial that we read mesh files as well, so that we can collect
    // material slots declared by objects. Material slots are required by the project
    // file updater, for instance when migrating projects from rev. 7 to rev. 8.
    ProjectFileReader reader;
    auto_release_ptr<Project> project(
        reader.read(
            input_filepath.c_str(),
            schema_filepath.string().c_str(),
            ProjectFileReader::OmitProjectFileUpdate));

    // Bail out if the project couldn't be loaded.
    if (project.get() == 0)
        return 1;

    // Update the project file to the desired revision.
    ProjectFileUpdater updater;
    if (cl.m_to_revision.is_set())
        updater.update(project.ref(), cl.m_to_revision.value());
    else updater.update(project.ref());

    // Write the project back to disk.
    const bool success =
        ProjectFileWriter::write(
            project.ref(),
            project->get_path(),
            ProjectFileWriter::OmitWritingGeometryFiles | ProjectFileWriter::OmitBringingAssets);

    return success ? 0 : 1;
}
Пример #16
0
void MainWindow::open_project(const QString& filepath)
{
    const filesystem::path path(filepath.toStdString());

    m_settings.insert_path(
        LAST_DIRECTORY_SETTINGS_KEY,
        path.parent_path().string());

    const bool successful =
        m_project_manager.load_project(filepath.toAscii().constData());

    if (successful)
        on_project_change();
    else  show_project_file_loading_failed_message_box(this, filepath);
}
Пример #17
0
 void EnsureDirectoryExists(const filesystem::path& directory)
 {
     if (!directory.is_directory())
     {
         filesystem::create_directory(directory);
     }
 }
Пример #18
0
    bool Parser::ParseWorkspace(const filesystem::path& filePath)
    {
        if (filePath.str().empty())
        {
            std::cout << "invalid workspace filename" << std::endl;
            return false;
        }

        WorkingDirectory::SetCurrent(filePath.make_absolute().parent_path().str());
        std::cout << "{ cwd : " << WorkingDirectory::GetCurrent() << " }" << std::endl;

        internal::EnsureDirectoryExists(outputDirectory_);

        auto workspace = JsonImporter::ImportWorkspace(pimpl_->GetFileManager(), filePath.filename());
        return ParseWorkspace(workspace.get());
    }
Пример #19
0
	bool FLogSource::open(const filesystem::path& path)
	{
		Synchronize on(*this);
		m_path = path.native();
		std::fstream log{ m_path, std::ios_base::out | std::ios_base::app };
		return log.is_open();
	}
Пример #20
0
std::unique_ptr<Workspace> JsonImporter::ImportWorkspace(FileManager& fileManager, const filesystem::path& workspaceFile)
{
    auto json = internal::ParseJsonFile(fileManager.GetFileSystem(), workspaceFile);

    if (internal::IsValidWorkspace(json))
    {
        auto workspace = std::make_unique<Workspace>();

        workspace->SetName(json["workspace"]);
        workspace->SetFile(workspaceFile);

        auto& projects = json["projects"];

        if (projects.is_array())
        {
            auto workspacePath = workspaceFile.parent_path();

            for (auto& project : projects)
            {
                workspace->AddProject(ImportProject(fileManager, workspacePath / project));
            }
        }

        return workspace;
    }

    return nullptr;
}
Пример #21
0
fs::path mpw_path() {

	static fs::path path;

	if (path.empty()) {
		std::error_code ec;
		const char *cp = getenv("PATH");
		if (!cp) cp = _PATH_DEFPATH;
		std::string s(cp);
		string_splitter ss(s, ':');
		for (; ss; ++ss) {
			if (ss->empty()) continue;
			fs::path p(*ss);
			p /= "mpw";

			if (fs::is_regular_file(p, ec)) {
				path = std::move(p);
				break;
			}
		}
		//also check /usr/local/bin
		if (path.empty()) {
			fs::path p = "/usr/local/bin/mpw";
			if (fs::is_regular_file(p, ec)) {
				path = std::move(p);
			}
		}

		if (path.empty()) {
			fs::path p = root() / "bin/mpw";
			if (fs::is_regular_file(p, ec)) {
				path = std::move(p);
			}
		}

		if (path.empty()) {
			fprintf(stderr, "Unable to find mpw executable\n");
			fprintf(stderr, "PATH = %s\n", s.c_str());
			path = "mpw";
		}
	}

	return path;
}
Пример #22
0
int main(int argc, const char* argv[])
{
    SuperLogger logger;
    Application::check_installation(logger);

    CommandLineHandler cl;
    cl.parse(argc, argv, logger);

    // Initialize the renderer's logger.
    global_logger().add_target(&logger.get_log_target());

    // Retrieve the command line arguments.
    const string& input_filepath = cl.m_filenames.values()[0];
    const string& output_filepath = cl.m_filenames.values()[1];
    const FluffParams params(cl);

    // Construct the schema file path.
    const filesystem::path schema_filepath =
          filesystem::path(Application::get_root_path())
        / "schemas"
        / "project.xsd";

    // Read the input project from disk.
    ProjectFileReader reader;
    auto_release_ptr<Project> project(
        reader.read(
            input_filepath.c_str(),
            schema_filepath.string().c_str()));

    // Bail out if the project couldn't be loaded.
    if (project.get() == 0)
        return 1;

    // Fluffify the project.
    make_fluffy(project.ref(), params);

    // Write the project back to disk.
    const bool success =
        ProjectFileWriter::write(
            project.ref(),
            output_filepath.c_str());

    return success ? 0 : 1;
}
Пример #23
0
bool writepath(filesystem::path& p, char* buf, size_t len, bool binary) {
	FILE* ofile;
	ofile = fopen((const char*)(p.native().c_str()), (binary?"wb":"w"));
	if(fwrite(buf, 1, len, ofile) != len) {
		fclose(ofile);
		return false;
	}
	fclose(ofile);
	return true;
}
Пример #24
0
    //! The function stores the specified file in the storage
    void file_collector::store_file(filesystem::path const& src_path)
    {
        // NOTE FOR THE FOLLOWING CODE:
        // Avoid using Boost.Filesystem functions that would call path::codecvt(). store_file() can be called
        // at process termination, and the global codecvt facet can already be destroyed at this point.
        // https://svn.boost.org/trac/boost/ticket/8642

        // Let's construct the new file name
        file_info info;
        info.m_TimeStamp = filesystem::last_write_time(src_path);
        info.m_Size = filesystem::file_size(src_path);

        filesystem::path file_name_path = src_path.filename();
        path_string_type file_name = file_name_path.native();
        info.m_Path = m_StorageDir / file_name_path;

        // Check if the file is already in the target directory
        filesystem::path src_dir = src_path.has_parent_path() ?
                            filesystem::system_complete(src_path.parent_path()) :
                            m_BasePath;
        const bool is_in_target_dir = filesystem::equivalent(src_dir, m_StorageDir);
        if (!is_in_target_dir)
        {
            if (filesystem::exists(info.m_Path))
            {
                // If the file already exists, try to mangle the file name
                // to ensure there's no conflict. I'll need to make this customizable some day.
                file_counter_formatter formatter(file_name.size(), 5);
                unsigned int n = 0;
                do
                {
                    path_string_type alt_file_name = formatter(file_name, n++);
                    info.m_Path = m_StorageDir / filesystem::path(alt_file_name);
                }
                while (filesystem::exists(info.m_Path) && n < (std::numeric_limits< unsigned int >::max)());
            }

            // The directory should have been created in constructor, but just in case it got deleted since then...
            filesystem::create_directories(m_StorageDir);
        }

        BOOST_LOG_EXPR_IF_MT(lock_guard< mutex > lock(m_Mutex);)
Пример #25
0
    bool Parser::ParseProject(const filesystem::path& filePath)
    {
        if (filePath.str().empty())
        {
            std::cout << "invalid project filename" << std::endl;
            return false;
        }

        auto project = JsonImporter::ImportProject(pimpl_->GetFileManager(), filePath);
        return ParseProject(project.get());
    }
Пример #26
0
bool ReadTexturesFromFile(const filesystem::path& lights_path, const filesystem::path& base_path, ID3D11Device* device, std::vector<TextureIdentifier>* textures) {
  nlohmann::json json_textures;

  bool load_ok = Core::ReadJsonFile(lights_path, &json_textures);
  if (!load_ok) {
    DXFW_TRACE(__FILE__, __LINE__, false, "Error reading textures file from %s", lights_path.string());
    return false;
  }

  return ReadTexturesFromJson(json_textures, base_path, device, textures);
}
Пример #27
0
inline
typename get_writer< std::wstring
                   , FormatTag
                   >::type
make_writer( const filesystem::path&              path
           , const image_write_info< FormatTag >& info
           )
{
    return make_writer( path.wstring()
                      , info
                      );
}
Пример #28
0
inline
typename get_writer< std::wstring
                   , FormatTag
                   >::type
make_writer( const filesystem::path& path
           , const FormatTag&        tag
           )
{
    return make_writer( path.wstring()
                      , tag
                      );
}
Пример #29
0
inline
typename get_scanline_reader< std::wstring
                            , FormatTag
                            >::type
make_scanline_reader( const filesystem::path& path
                    , FormatTag const&
                    )
{
    return make_scanline_reader( path.wstring()
                               , image_read_settings< FormatTag >()
                               );
}
Пример #30
0
inline
typename get_dynamic_image_writer< std::wstring
, FormatTag
>::type
make_dynamic_image_writer( const filesystem::path& path
                           , const FormatTag&
                         )
{
    return make_dynamic_image_writer( path.wstring()
                                      , image_write_info< FormatTag >()
                                    );
}