Difference between revisions of "URIs and Filenames"
Jump to navigation
Jump to search
(Inkscape::URI, Inkscape::IO::UriInputStream) |
(UriInputStream w/ data:) |
||
Line 17: | Line 17: | ||
** <code>[https://gitlab.com/inkscape/inkscape/blob/master/src/object/uri.h Inkscape::URI]</code> | ** <code>[https://gitlab.com/inkscape/inkscape/blob/master/src/object/uri.h Inkscape::URI]</code> | ||
** <code>[https://gitlab.com/inkscape/inkscape/blob/master/src/io/uristream.h Inkscape::IO::UriInputStream]</code> | ** <code>[https://gitlab.com/inkscape/inkscape/blob/master/src/io/uristream.h Inkscape::IO::UriInputStream]</code> | ||
*** Why does <code>UriInputStream</code> not decode <code>data:</code> URIs? | |||
* [https://gitlab.com/inkscape/inkscape/merge_requests/364 Merge Request !364] (some <code>Inkscape::URI</code> refactoring) | |||
== Notes == | == Notes == |
Revision as of 10:14, 24 October 2018
Inkscape's handling of URIs and Filenames is a complete mess!
- What some variable names claim to be URIs are actually filenames and visa-versa.
- There is a lot of code duplication. (e.g.
src/io/dir-utils.cpp
andsrc/xml/rebase-hrefs.cpp
).
To do
- Put all our own URI and Filename handling code in
src/io
(or at least list in README in that directory). - Convert all routines to use:
std::string
(byte string) for file names and paths.Glib::ustring
(unicode string) for URIs
- Rely on Glib functions where possible. Glib functions handle many of the WIN32/LINUX/MAC issues automatically.
- Use Gio::File class.
- Use Glib utility and conversion functions (see below).
- Remove 'sodipodi-absref' as this leaks user directory information.
- Clarify whether/when to use these classes:
Inkscape::URI
Inkscape::IO::UriInputStream
- Why does
UriInputStream
not decodedata:
URIs?
- Why does
- Merge Request !364 (some
Inkscape::URI
refactoring)
Notes
- URIs should always use '/'. You cannot use Glib filename functions to handle URIs as they will use '/' or '\' depending on operating system.
- Use relative paths (URIs!) where possible as this allows moving documents with resources together.
glibmm Documentation
Misc. Utility Functions
- bool Glib::path_is_absolute (const std::string& filename)
- Returns true if the given filename is an absolute file name, i.e. it contains a full path from the root directory such as "/usr/local" on UNIX or "C:\\windows" on Windows systems. More...
- std::string Glib::path_skip_root (const std::string& filename)
- Returns the remaining part of filename after the root component, i.e. after the "/" on UNIX or "C:\\" on Windows. More...
- std::string Glib::path_get_basename (const std::string& filename)
- Gets the name of the file without any leading directory components. More...
- std::string Glib::path_get_dirname (const std::string& filename)
- Gets the directory components of a file name. More...
- std::string Glib::build_filename (const Glib::ArrayHandle< std::string >& elements)
- Creates a filename from a series of elements using the correct separator for filenames. More...
- std::string Glib::build_filename (const std::string& elem1, const std::string& elem2)
- Creates a filename from two elements using the correct separator for filenames. More...
- std::string Glib::build_filename (const std::string& elem1, const std::string& elem2, const std::string& elem3)
- Creates a filename from three elements using the correct separator for filenames. More...
etc.
Conversions
- Glib::ustring Glib::filename_to_utf8 (const std::string& opsys_string)
- Converts a string which is in the encoding used for filenames into a UTF-8 string.
- std::string Glib::filename_from_utf8 (const Glib::ustring& utf8_string)
- Converts a string from UTF-8 to the encoding used for filenames.
- std::string Glib::filename_from_uri (const Glib::ustring& uri, Glib::ustring& hostname)
- Converts an escaped UTF-8 encoded URI to a local filename in the encoding used for filenames.
- std::string Glib::filename_from_uri (const Glib::ustring& uri)
- Converts an escaped UTF-8 encoded URI to a local filename in the encoding used for filenames.
- Glib::ustring Glib::filename_to_uri (const std::string& filename, const Glib::ustring& hostname)
- Converts an absolute filename to an escaped UTF-8 encoded URI.
- Glib::ustring Glib::filename_to_uri (const std::string& filename)
- Converts an absolute filename to an escaped UTF-8 encoded URI.
- Glib::ustring Glib::filename_display_basename (const std::string& filename)
- Returns the display basename for the particular filename, guaranteed to be valid UTF-8.
- Glib::ustring Glib::filename_display_name (const std::string& filename)
- Converts a filename into a valid UTF-8 string.