_moo_path_is_absolute()
parent
8a0aec4b54
commit
7efbcd4de1
|
@ -464,7 +464,7 @@ get_folder (MooFileSystem *fs,
|
|||
#endif /* __WIN32__ */
|
||||
|
||||
/* XXX check the caller */
|
||||
if (!g_path_is_absolute (path))
|
||||
if (!_moo_path_is_absolute (path))
|
||||
{
|
||||
g_set_error (error, MOO_FILE_ERROR,
|
||||
MOO_FILE_ERROR_BAD_FILENAME,
|
||||
|
@ -541,7 +541,7 @@ create_folder (G_GNUC_UNUSED MooFileSystem *fs,
|
|||
g_return_val_if_fail (path != NULL, FALSE);
|
||||
|
||||
/* XXX check the caller */
|
||||
if (!g_path_is_absolute (path))
|
||||
if (!_moo_path_is_absolute (path))
|
||||
{
|
||||
g_set_error (error, MOO_FILE_ERROR,
|
||||
MOO_FILE_ERROR_BAD_FILENAME,
|
||||
|
@ -685,7 +685,7 @@ delete_file (G_GNUC_UNUSED MooFileSystem *fs,
|
|||
gboolean isdir;
|
||||
|
||||
g_return_val_if_fail (path != NULL, FALSE);
|
||||
g_return_val_if_fail (g_path_is_absolute (path), FALSE);
|
||||
g_return_val_if_fail (_moo_path_is_absolute (path), FALSE);
|
||||
|
||||
if (g_file_test (path, G_FILE_TEST_IS_SYMLINK))
|
||||
isdir = FALSE;
|
||||
|
@ -722,8 +722,8 @@ move_file_unix (G_GNUC_UNUSED MooFileSystem *fs,
|
|||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (old_path && new_path, FALSE);
|
||||
g_return_val_if_fail (g_path_is_absolute (old_path), FALSE);
|
||||
g_return_val_if_fail (g_path_is_absolute (new_path), FALSE);
|
||||
g_return_val_if_fail (_moo_path_is_absolute (old_path), FALSE);
|
||||
g_return_val_if_fail (_moo_path_is_absolute (new_path), FALSE);
|
||||
|
||||
/* XXX */
|
||||
if (_moo_rename (old_path, new_path))
|
||||
|
@ -762,7 +762,7 @@ make_path_unix (G_GNUC_UNUSED MooFileSystem *fs,
|
|||
g_return_val_if_fail (display_name != NULL, NULL);
|
||||
|
||||
/* XXX check the caller */
|
||||
if (!g_path_is_absolute (base_path))
|
||||
if (!_moo_path_is_absolute (base_path))
|
||||
{
|
||||
g_set_error (error, MOO_FILE_ERROR,
|
||||
MOO_FILE_ERROR_BAD_FILENAME,
|
||||
|
@ -842,7 +842,7 @@ parse_path_unix (MooFileSystem *fs,
|
|||
g_return_val_if_fail (path_utf8 && path_utf8[0], FALSE);
|
||||
|
||||
/* XXX check the caller */
|
||||
if (!g_path_is_absolute (path_utf8))
|
||||
if (!_moo_path_is_absolute (path_utf8))
|
||||
{
|
||||
g_set_error (error, MOO_FILE_ERROR,
|
||||
MOO_FILE_ERROR_BAD_FILENAME,
|
||||
|
@ -915,7 +915,7 @@ get_absolute_path_unix (G_GNUC_UNUSED MooFileSystem *fs,
|
|||
return g_strdup (home);
|
||||
}
|
||||
|
||||
if (g_path_is_absolute (short_name))
|
||||
if (_moo_path_is_absolute (short_name))
|
||||
return g_strdup (short_name);
|
||||
|
||||
if (current_dir)
|
||||
|
@ -1068,7 +1068,7 @@ make_path_win32 (G_GNUC_UNUSED MooFileSystem *fs,
|
|||
const char *display_name,
|
||||
G_GNUC_UNUSED GError **error)
|
||||
{
|
||||
g_return_val_if_fail (g_path_is_absolute (base_path), NULL);
|
||||
g_return_val_if_fail (_moo_path_is_absolute (base_path), NULL);
|
||||
g_return_val_if_fail (display_name != NULL, NULL);
|
||||
return g_strdup_printf ("%s\\%s", base_path, display_name);
|
||||
}
|
||||
|
@ -1090,7 +1090,7 @@ parse_path_win32 (MooFileSystem *fs,
|
|||
gsize len;
|
||||
|
||||
g_return_val_if_fail (path_utf8 && path_utf8[0], FALSE);
|
||||
g_return_val_if_fail (g_path_is_absolute (path_utf8), FALSE);
|
||||
g_return_val_if_fail (_moo_path_is_absolute (path_utf8), FALSE);
|
||||
|
||||
separator = strrchr (path_utf8, '\\');
|
||||
g_return_val_if_fail (separator != NULL, FALSE);
|
||||
|
@ -1139,7 +1139,7 @@ get_absolute_path_win32 (G_GNUC_UNUSED MooFileSystem *fs,
|
|||
{
|
||||
g_return_val_if_fail (short_name && short_name[0], NULL);
|
||||
|
||||
if (g_path_is_absolute (short_name))
|
||||
if (_moo_path_is_absolute (short_name))
|
||||
return g_strdup (short_name);
|
||||
|
||||
if (current_dir)
|
||||
|
|
|
@ -1066,7 +1066,7 @@ moo_file_view_chdir_real (MooFileView *fileview,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_path_is_absolute (new_dir) || !fileview->priv->current_dir)
|
||||
if (_moo_path_is_absolute (new_dir) || !fileview->priv->current_dir)
|
||||
{
|
||||
real_new_dir = g_strdup (new_dir);
|
||||
}
|
||||
|
|
|
@ -439,7 +439,7 @@ _moo_chdir (const char *path)
|
|||
// working_dir = g_get_current_dir ();
|
||||
// g_return_val_if_fail (working_dir != NULL, g_strdup (filename));
|
||||
//
|
||||
// if (!g_path_is_absolute (filename))
|
||||
// if (!_moo_path_is_absolute (filename))
|
||||
// {
|
||||
// freeme = g_build_filename (working_dir, filename, NULL);
|
||||
// filename = freeme;
|
||||
|
@ -723,12 +723,7 @@ normalize_path (const char *filename)
|
|||
|
||||
g_assert (filename && filename[0]);
|
||||
|
||||
if (!g_path_is_absolute (filename)
|
||||
#ifdef __WIN32__
|
||||
/* 'C:' is an absolute path even if glib doesn't like it */
|
||||
&& filename[1] != ':'
|
||||
#endif
|
||||
)
|
||||
if (!_moo_path_is_absolute (filename))
|
||||
{
|
||||
char *working_dir = g_get_current_dir ();
|
||||
g_return_val_if_fail (working_dir != NULL, g_strdup (filename));
|
||||
|
@ -755,13 +750,20 @@ _moo_normalize_file_path (const char *filename)
|
|||
return normalize_path (filename);
|
||||
}
|
||||
|
||||
#if 0
|
||||
char *
|
||||
_moo_normalize_dir_path (const char *filename)
|
||||
gboolean
|
||||
_moo_path_is_absolute (const char *path)
|
||||
{
|
||||
return normalize_path (filename, TRUE);
|
||||
}
|
||||
g_return_val_if_fail (path != NULL, FALSE);
|
||||
return g_path_is_absolute (path)
|
||||
#ifdef __WIN32__
|
||||
/* 'C:' is an absolute path even if glib doesn't like it */
|
||||
/* This will match nonsense like 1:23:23 too, but that's not
|
||||
* a valid path, and it's better to have "1:23:23" in the error
|
||||
* message than "c:\some\silly\current\dir\1:23:23" */
|
||||
|| filename[1] == ':'
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
#ifdef MOO_ENABLE_UNIT_TESTS
|
||||
|
@ -802,6 +804,7 @@ make_cases (gboolean unix_paths)
|
|||
const char *abs_files_unix[] = {
|
||||
"/usr", "/usr",
|
||||
"/usr/", "/usr",
|
||||
"/usr///", "/usr",
|
||||
"///usr////", "/usr",
|
||||
"/", "/",
|
||||
"//", "/",
|
||||
|
@ -816,6 +819,7 @@ make_cases (gboolean unix_paths)
|
|||
const char *abs_files_win32[] = {
|
||||
"C:", "C:\\",
|
||||
"C:\\", "C:\\",
|
||||
"C:\\\\", "C:\\",
|
||||
"C:\\foobar", "C:\\foobar",
|
||||
"C:\\foobar\\", "C:\\foobar",
|
||||
"C:\\foobar\\\\\\", "C:\\foobar",
|
||||
|
@ -833,6 +837,7 @@ make_cases (gboolean unix_paths)
|
|||
"././././/", NULL,
|
||||
"foobar", "foobar",
|
||||
"foobar/", "foobar",
|
||||
"foobar//", "foobar",
|
||||
"foobar/..", NULL,
|
||||
"foobar/./..", NULL,
|
||||
"foobar/../", NULL,
|
||||
|
@ -850,6 +855,7 @@ make_cases (gboolean unix_paths)
|
|||
"foobar/com", "foobar\\com",
|
||||
".\\.\\.\\.\\\\", NULL,
|
||||
"foobar\\", "foobar",
|
||||
"foobar\\\\", "foobar",
|
||||
"foobar\\..", NULL,
|
||||
"foobar\\.\\..", NULL,
|
||||
"foobar\\..\\", NULL,
|
||||
|
@ -926,6 +932,8 @@ make_cases (gboolean unix_paths)
|
|||
g_ptr_array_add (paths, g_strdup (parent_dir));
|
||||
g_ptr_array_add (paths, g_strdup (".././"));
|
||||
g_ptr_array_add (paths, g_strdup (parent_dir));
|
||||
g_ptr_array_add (paths, g_strdup ("..//"));
|
||||
g_ptr_array_add (paths, g_strdup (parent_dir));
|
||||
#ifdef __WIN32__
|
||||
g_ptr_array_add (paths, g_strdup ("..\\"));
|
||||
g_ptr_array_add (paths, g_strdup (parent_dir));
|
||||
|
@ -933,6 +941,8 @@ make_cases (gboolean unix_paths)
|
|||
g_ptr_array_add (paths, g_strdup (parent_dir));
|
||||
g_ptr_array_add (paths, g_strdup ("..\\.\\"));
|
||||
g_ptr_array_add (paths, g_strdup (parent_dir));
|
||||
g_ptr_array_add (paths, g_strdup ("..\\\\"));
|
||||
g_ptr_array_add (paths, g_strdup (parent_dir));
|
||||
#endif
|
||||
g_free (parent_dir);
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ char **moo_filenames_from_locale (char **files);
|
|||
char *moo_filename_from_locale (const char *file);
|
||||
|
||||
char *_moo_normalize_file_path (const char *filename);
|
||||
gboolean _moo_path_is_absolute (const char *path);
|
||||
|
||||
/*
|
||||
* C library and WinAPI functions wrappers analogous to glib/gstdio.h
|
||||
|
|
Loading…
Reference in New Issue