Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
dir-util.cpp File Reference

TODO: insert short description here. More...

Go to the source code of this file.

Functions

std::string sp_relative_path_from_path (std::string const &path, std::string const &base)
 Returns a form of path relative to base if that is easy to construct (eg if path appears to be in the directory specified by base), otherwise returns path.
 
char const * sp_extension_from_path (char const *const path)
 
char * inkscape_rel2abs (const char *path, const char *base, char *result, const size_t size)
 Convert a relative path name into absolute.
 
char * inkscape_abs2rel (const char *path, const char *base, char *result, const size_t size)
 
char * prepend_current_dir_if_relative (gchar const *uri)
 

Variables

static char const dots [] = {'.', '.', G_DIR_SEPARATOR, '\0'}
 
static char const *const parent = dots
 
static char const *const current = dots + 1
 

Detailed Description

TODO: insert short description here.

Utility functions for filenames.

Definition in file dir-util.cpp.

Function Documentation

◆ inkscape_abs2rel()

char * inkscape_abs2rel ( const char *  path,
const char *  base,
char *  result,
const size_t  size 
)

Definition at line 159 of file dir-util.cpp.

References result, and size.

◆ inkscape_rel2abs()

char * inkscape_rel2abs ( char const *  path,
char const *  base,
char *  result,
size_t const  size 
)

Convert a relative path name into absolute.

If path is already absolute, does nothing except copying path to result.

Parameters
pathrelative path.
basebase directory (must be absolute path).
resultresult buffer.
sizesize of result buffer.
Returns
!= NULL: absolute path == NULL: error

based on functions by Shigio Yamaguchi. FIXME:TODO: force it to also do path normalization of the entire resulting path, i.e. get rid of any .. and . in any place, even if 'path' is already absolute (now it returns it unchanged in this case)

Definition at line 73 of file dir-util.cpp.

References current, parent, result, and size.

Referenced by prepend_current_dir_if_relative().

◆ prepend_current_dir_if_relative()

char * prepend_current_dir_if_relative ( gchar const *  uri)

Definition at line 229 of file dir-util.cpp.

References inkscape_rel2abs().

Referenced by SPDocument::createDoc(), and SPDocument::do_change_filename().

◆ sp_extension_from_path()

char const * sp_extension_from_path ( char const *const  path)

Definition at line 51 of file dir-util.cpp.

◆ sp_relative_path_from_path()

std::string sp_relative_path_from_path ( std::string const &  path,
std::string const &  base 
)

Returns a form of path relative to base if that is easy to construct (eg if path appears to be in the directory specified by base), otherwise returns path.

Parameters
pathis expected to be an absolute path.
baseis expected to be either empty or the absolute path of a directory.
Returns
a relative version of the path, if reasonable.
See also
inkscape_abs2rel for a more sophisticated version.
prepend_current_dir_if_relative.

Definition at line 21 of file dir-util.cpp.

References result.

Referenced by Inkscape::Shortcuts::get_file_names(), and Inkscape::Shortcuts::init().

Variable Documentation

◆ current

char const* const current = dots + 1
static

Definition at line 71 of file dir-util.cpp.

Referenced by Inkscape::Extension::Internal::StyleMemory::_push(), Tracer::Kopf2011::_remove_crossing_edges_safe(), Inkscape::Application::activate_desktop(), Inkscape::UI::Widget::GradientEditor::add_stop(), Inkscape::UI::Dialog::InkscapePreferences::AddNewObjectsStyle(), Inkscape::LivePathEffect::LPEEmbroderyStitchOrdering::AssertIsTour(), Inkscape::UI::Dialog::DocumentProperties::build_scripting(), Inkscape::UI::Dialog::DocumentProperties::changeEmbeddedScript(), Inkscape::UI::Dialog::CloneTiler::CloneTiler(), Inkscape::LivePathEffect::LPEFillBetweenMany::doEffect(), Inkscape::UI::Dialog::LivePathEffectEditor::effect_list_reload(), Inkscape::UI::Dialog::StartScreen::enlist_keys(), Inkscape::Extension::ExpirationTimer::expired(), Inkscape::Extension::Internal::StyleMemory::get_changes(), Inkscape::UI::Widget::UnitMenu::getUnit(), Inkscape::ObjectSet::group(), Inkscape::UI::Dialog::InkscapePreferences::initPageIO(), inkscape_rel2abs(), Inkscape::LivePathEffect::LPEEmbroderyStitchOrdering::LinearizeTour(), Inkscape::Preferences::mergeStyle(), next_item_from_list(), objects_query_baselines(), Inkscape::UI::Dialog::Transformation::onReplaceMatrixToggled(), Inkscape::LivePathEffect::LPEEmbroderyStitchOrdering::OrderGroups(), SPLPEItem::performOnePathEffect(), SPLPEItem::performPathEffect(), Inkscape::UI::Dialog::DocumentProperties::populate_linked_profiles_box(), Inkscape::UI::Dialog::DocumentProperties::populate_script_lists(), rdf_match_license(), RecDistanceToCubic(), Inkscape::UI::Widget::regenerate_tile_images(), Inkscape::UI::Dialog::DocumentProperties::removeExternalScript(), Inkscape::searchUpwards(), select_invert(), Inkscape::DrawingGroup::setChildTransform(), Inkscape::ObjectSet::setClipGroup(), Inkscape::ObjectSet::setMask(), SPPage::setPageIndex(), Inkscape::DrawingPattern::setPatternToUserTransform(), Inkscape::DrawingItem::setTransform(), Inkscape::UI::Tools::sp_flood_do_flood_fill(), sp_gradient_add_stop(), sp_guide_delete_all_guides(), sp_item_set_gradient(), sp_repr_css_change(), Inkscape::Colors::to_gamut_css(), Inkscape::Extension::ExpirationTimer::touch(), Inkscape::UI::Dialog::Transformation::updatePageTransform(), and Inkscape::UI::Widget::RotateableStrokeWidth::value_adjust().

◆ dots

char const dots[] = {'.', '.', G_DIR_SEPARATOR, '\0'}
static

◆ parent

char const* const parent = dots
static

Definition at line 70 of file dir-util.cpp.

Referenced by SnapManager::_findCandidates(), Inkscape::Display::TranslucencyGroup::_generateTranslucentItems(), _getObjectsByClassRecursive(), _getObjectsByElementRecursive(), _getObjectsBySelectorRecursive(), SPStyle::_mergeObjectStylesheet(), Inkscape::ObjectSet::_pathBoolOp(), Inkscape::UI::Dialog::SelectorsDialog::_removeFromSelector(), Inkscape::UI::Toolbar::TextToolbar::_selectionChanged(), Inkscape::LivePathEffect::LPEPowerClip::add(), Inkscape::UI::Dialog::InkscapePreferences::AddPage(), addStop(), Geom::RTree::adjust_tree(), Inkscape::UI::Dialog::CloneTiler::apply(), Inkscape::ObjectSet::applyAffine(), ascend_while_first(), Inkscape::ObjectSet::breakApart(), Inkscape::Extension::Internal::PrintMetafile::brush_classify(), Inkscape::UI::Dialog::can_collapse(), Inkscape::CanvasItem::CanvasItem(), SPIFloat::cascade(), SPIScale24::cascade(), SPILength::cascade(), SPILengthOrNormal::cascade(), SPIFontVariationSettings::cascade(), SPIEnum< T >::cascade(), SPIString::cascade(), SPIColor::cascade(), SPIPaint::cascade(), SPIPaintOrder::cascade(), SPIDashArray::cascade(), SPIFilter::cascade(), SPIFontSize::cascade(), SPIBaselineShift::cascade(), SPITextDecorationLine::cascade(), SPITextDecorationStyle::cascade(), SPITextDecoration::cascade(), SPStyle::cascade(), Inkscape::UI::Dialog::choose_file(), Inkscape::choose_file_open(), Inkscape::choose_file_open(), Inkscape::choose_file_open(), Inkscape::choose_file_open_images(), Inkscape::choose_file_save(), Inkscape::choose_file_save(), Inkscape::UI::Handle::clicked(), Inkscape::ObjectSet::clone(), Inkscape::ObjectSet::cloneOriginalPathLPE(), Inkscape::UI::Dialog::XmlTree::cmd_delete_node(), Inkscape::UI::Dialog::XmlTree::cmd_duplicate_node(), Inkscape::UI::Dialog::XmlTree::cmd_indent_node(), Inkscape::UI::Dialog::XmlTree::cmd_lower_node(), Inkscape::UI::Dialog::XmlTree::cmd_raise_node(), Inkscape::UI::Dialog::XmlTree::cmd_unindent_node(), Inkscape::UI::Dialog::DialogContainer::column_empty(), Inkscape::ObjectSet::combine(), Geom::RTree::condense_tree(), SPBox3D::convert_to_group(), KnotHolderEntity::create(), create_flowtext_with_internal_frame(), create_text_with_rectangle(), Inkscape::ObjectSet::createBitmapCopy(), SPBox3D::createBox3D(), SPDocument::createDoc(), SPDocument::createNewDoc(), GrDrag::deleteSelected(), Inkscape::ObjectSet::duplicate(), Inkscape::UI::Dialog::FilterEffectsDialog::FilterModifier::duplicate_filter(), Inkscape::UI::Dialog::extract_colors(), Inkscape::extract_image(), find_containing_child(), Inkscape::UI::find_focusable_widget(), find_label(), Inkscape::UI::find_widget_by_name(), flowtext_to_text(), Inkscape::UI::for_each_parent(), Inkscape::UI::Widget::PopoverMenuItem::get_menu(), Inkscape::UI::Dialog::DialogNotebook::get_page_notebook(), Inkscape::XML::get_parent(), Inkscape::UI::Widget::get_scrollable_ancestor(), group_exit(), Inkscape::UI::Widget::FontCollectionSelector::icon_cell_data_func(), Inkscape::UI::Dialog::XmlTree::in_dt_coordsys(), Inkscape::DocumentSubset::indexOf(), inkscape_rel2abs(), Geom::RedBlackTree::insert(), Inkscape::UI::Dialog::DialogMultipaned::insert(), Inkscape::UI::is_descendant_of(), item_to_paths(), Geom::RedBlackTree::left_rotate(), Inkscape::UI::Toolbar::TextToolbar::lineheight_unit_changed(), Inkscape::UI::Toolbar::TextToolbar::lineheight_value_changed(), Inkscape::UI::NewFromTemplate::load_new_from_template(), SPIFloat::merge(), SPIScale24::merge(), SPILength::merge(), SPILengthOrNormal::merge(), SPIFontVariationSettings::merge(), SPIEnum< T >::merge(), SPIString::merge(), SPIColor::merge(), SPIPaint::merge(), SPIPaintOrder::merge(), SPIDashArray::merge(), SPIFilter::merge(), SPIFontSize::merge(), SPIBaselineShift::merge(), SPITextDecorationLine::merge(), SPITextDecorationStyle::merge(), SPITextDecoration::merge(), SPStyle::merge(), SPRoot::modified(), Inkscape::UI::NewFromTemplate::NewFromTemplate(), Inkscape::LivePathEffect::LPETransform2Pts::newWidget(), Inkscape::EventLog::notifyUndoExpired(), Inkscape::UI::Dialog::CloneTiler::number_of_clones(), Inkscape::Selection::numberOfParents(), objects_have_equal_style(), objects_query_fillstroke(), Inkscape::UI::Widget::FontCollectionSelector::on_delete_button_pressed(), Inkscape::UI::Widget::FontCollectionSelector::on_delete_icon_clicked(), Inkscape::UI::Widget::FontCollectionSelector::on_drop_drop(), Inkscape::UI::Widget::FontCollectionSelector::on_drop_motion(), Inkscape::UI::Widget::FontCollectionSelector::on_edit_button_pressed(), Inkscape::UI::Dialog::BatchItem::on_parent_changed(), Inkscape::UI::Widget::FontCollectionSelector::on_rename_collection(), Inkscape::UI::Widget::FontCollectionSelector::on_selection_changed(), Inkscape::UI::Dialog::XmlTree::on_tree_select_row_enable(), Inkscape::Extension::ParamOptionGroup::ParamOptionGroupOption::ParamOptionGroupOption(), Box3DSide::perspective(), Inkscape::Extension::Internal::SvgBuilder::popGroup(), Inkscape::UI::popup_at(), SPStyle::read(), Geom::RTree::recalculate_bounding_box(), Inkscape::UI::Dialog::CloneTiler::remove(), SPDesktopWidget::remove_from_top_toolbar_or_hbox(), Geom::RTree::remove_record_from_parent(), SPDesktopWidget::repack_snaptoolbar(), retransientize_dialogs(), Geom::RedBlackTree::right_rotate(), Inkscape::run(), Inkscape::UI::Dialog::SaveTemplate::save_document_as_template(), Inkscape::UI::Dialog::SaveTemplate::save_template(), Inkscape::UI::Dialog::SaveTemplate::SaveTemplate(), Inkscape::UI::set_icon_sizes(), Inkscape::UI::set_icon_sizes(), Box3DSide::set_shape(), Inkscape::UI::Toolbar::ToolToolbar::set_visible_buttons(), Inkscape::ObjectSet::setClipGroup(), Inkscape::BooleanBuilder::shape_commit(), Inkscape::Text::Layout::show(), show_all_images(), Inkscape::UI::Tools::GradientTool::simplify(), sp_item_group_ungroup_handle_clones(), sp_item_list_common_parent_group(), sp_item_list_to_curves(), sp_lpe_item_cleanup_original_path_recursive(), sp_lpe_item_update_patheffect(), sp_marker_show_instance(), sp_repr_css_attr_inherited_recursive(), sp_repr_unparent(), Inkscape::UI::Tools::sp_select_context_up_one_layer(), sp_selected_path_create_offset_object(), sp_selected_path_do_offset(), sp_selection_paste_impl(), Inkscape::UI::Tools::sp_spray_recursive(), Inkscape::UI::Tools::sp_tweak_dilate_recursive(), Inkscape::SelTrans::stamp(), Inkscape::UI::Dialog::XmlTree::stopNodeEditing(), Inkscape::Async::SubProgress< T, S >::SubProgress(), Inkscape::Extension::Internal::SvgBuilder::SvgBuilder(), text_put_on_path(), text_to_glyphs(), Inkscape::ObjectSet::tile(), Inkscape::ObjectSet::toMarker(), Inkscape::UI::Dialog::CloneTiler::unclump(), Inkscape::UI::Toolbar::TextToolbar::unindent_node(), Inkscape::UI::Dialog::ObjectsPanel::unpackToObject(), Inkscape::ObjectSet::unsetMask(), SPSymbol::unSymbol(), SPRoot::update(), SPSymbol::update(), Inkscape::UI::Dialog::BatchItem::update_selected(), Inkscape::SelectionDescriber::updateMessage(), and Inkscape::UI::Dialog::XmlTree::xml_tree_node_mutable().