Add utils_path_skip_root(), a relative path safe variant of g_path_skip_root (forgotten patch by Colomban Wendling, #2518658).
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3663 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
1d7a1226c4
commit
a6cecbd433
@ -1,6 +1,13 @@
|
||||
2009-03-27 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
||||
|
||||
* src/keyfile.c, src/utils.c, src/utils.h:
|
||||
Add utils_path_skip_root(), a relative path safe variant of
|
||||
g_path_skip_root (forgotten patch by Colomban Wendling, #2518658).
|
||||
|
||||
|
||||
2009-03-26 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
||||
|
||||
* src\main.c, src\plugins.c, src\win32.c, src\win32.h:
|
||||
* src/main.c, src/plugins.c, src/win32.c, src/win32.h:
|
||||
Use g_win32_get_package_installation_directory_of_module() on Windows
|
||||
with newer GLib versions instead of deprecated API.
|
||||
* src/keybindings.c:
|
||||
|
@ -231,7 +231,6 @@ static gchar *get_session_file_string(GeanyDocument *doc)
|
||||
{
|
||||
gchar *fname;
|
||||
gchar *locale_filename;
|
||||
gchar *rootless_filename;
|
||||
GeanyFiletype *ft = doc->file_type;
|
||||
|
||||
if (ft == NULL) /* can happen when saving a new file when quitting */
|
||||
@ -243,10 +242,7 @@ static gchar *get_session_file_string(GeanyDocument *doc)
|
||||
* writing with usual colons which must never appear in a filename and replace them
|
||||
* back when we read the file again from the file.
|
||||
* (g_path_skip_root() to skip C:\... on Windows) */
|
||||
rootless_filename = (gchar *) g_path_skip_root(locale_filename);
|
||||
if (locale_filename == NULL)
|
||||
rootless_filename = locale_filename;
|
||||
g_strdelimit(rootless_filename, ";", ':');
|
||||
g_strdelimit((gchar*) utils_path_skip_root(locale_filename), ";", ':');
|
||||
|
||||
fname = g_strdup_printf("%d;%s;%d;%d;%d;%d;%d;%s;%d",
|
||||
sci_get_current_position(doc->editor->sci),
|
||||
@ -894,7 +890,6 @@ static gboolean open_session_file(gchar **tmp, guint len)
|
||||
guint pos;
|
||||
const gchar *ft_name;
|
||||
gchar *locale_filename;
|
||||
gchar *rootless_filename;
|
||||
gint enc_idx, indent_type;
|
||||
gboolean ro, auto_indent, line_wrapping;
|
||||
/** TODO when we have a global pref for line breaking, use its value */
|
||||
@ -911,10 +906,7 @@ static gboolean open_session_file(gchar **tmp, guint len)
|
||||
/* try to get the locale equivalent for the filename */
|
||||
locale_filename = utils_get_locale_from_utf8(tmp[7]);
|
||||
/* replace ':' back with ';' (see get_session_file_string for details) */
|
||||
rootless_filename = (gchar *) g_path_skip_root(locale_filename);
|
||||
if (locale_filename == NULL)
|
||||
rootless_filename = locale_filename;
|
||||
g_strdelimit(rootless_filename, ":", ';');
|
||||
g_strdelimit((gchar*) utils_path_skip_root(locale_filename), ":", ';');
|
||||
|
||||
if (len > 8)
|
||||
line_breaking = atoi(tmp[8]);
|
||||
|
13
src/utils.c
13
src/utils.c
@ -319,6 +319,19 @@ gboolean utils_is_absolute_path(const gchar *path)
|
||||
}
|
||||
|
||||
|
||||
/* Skips root if path is absolute, do nothing otherwise.
|
||||
* This is a relative-safe version of g_path_skip_root().
|
||||
*/
|
||||
const gchar *utils_path_skip_root(const gchar *path)
|
||||
{
|
||||
const gchar *path_relative;
|
||||
|
||||
path_relative = g_path_skip_root(path);
|
||||
|
||||
return (path_relative != NULL) ? path_relative : path;
|
||||
}
|
||||
|
||||
|
||||
gdouble utils_scale_round(gdouble val, gdouble factor)
|
||||
{
|
||||
/*val = floor(val * factor + 0.5);*/
|
||||
|
@ -76,6 +76,8 @@ gboolean utils_atob(const gchar *str);
|
||||
|
||||
gboolean utils_is_absolute_path(const gchar *path);
|
||||
|
||||
const gchar *utils_path_skip_root(const gchar *path);
|
||||
|
||||
gdouble utils_scale_round(gdouble val, gdouble factor);
|
||||
|
||||
gboolean utils_str_equal(const gchar *a, const gchar *b);
|
||||
|
Loading…
x
Reference in New Issue
Block a user