fileinfo: mark lost+found/ root directory as hidden

This was reported in bug 689800.

https://bugzilla.gnome.org/show_bug.cgi?id=689800

Signed-off-by: David Zeuthen <zeuthen@gmail.com>
This commit is contained in:
David Zeuthen 2012-12-06 16:21:58 -05:00
parent 510ba9b4ef
commit d77948eadf
3 changed files with 49 additions and 0 deletions

View File

@ -1806,6 +1806,46 @@ _g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
return res;
}
#ifdef G_OS_UNIX
gboolean
_g_local_file_is_lost_found_dir (const char *path, dev_t path_dev)
{
gboolean ret = FALSE;
gchar *mount_dir = NULL;
size_t mount_dir_len;
GStatBuf statbuf;
if (!g_str_has_suffix (path, "/lost+found"))
goto out;
mount_dir = find_mountpoint_for (path, path_dev);
if (mount_dir == NULL)
goto out;
mount_dir_len = strlen (mount_dir);
/* We special-case rootfs ('/') since it's the only case where
* mount_dir ends in '/'
*/
if (mount_dir_len == 1)
mount_dir_len--;
if (mount_dir_len + strlen ("/lost+found") != strlen (path))
goto out;
if (g_lstat (path, &statbuf) != 0)
goto out;
if (!(S_ISDIR (statbuf.st_mode) &&
statbuf.st_uid == 0 &&
statbuf.st_gid == 0))
goto out;
ret = TRUE;
out:
g_free (mount_dir);
return ret;
}
#endif
static gboolean
g_local_file_trash (GFile *file,

View File

@ -1782,6 +1782,11 @@ _g_local_file_info_get (const char *basename,
if (stat_ok)
set_info_from_stat (info, &statbuf, attribute_matcher);
#ifdef G_OS_UNIX
if (stat_ok && _g_local_file_is_lost_found_dir (path, statbuf.st_dev))
g_file_info_set_is_hidden (info, TRUE);
#endif
#ifndef G_OS_WIN32
if (basename != NULL &&
(basename[0] == '.' ||

View File

@ -58,6 +58,10 @@ typedef struct
gboolean _g_local_file_has_trash_dir (const char *dirname,
dev_t dir_dev);
#ifdef G_OS_UNIX
gboolean _g_local_file_is_lost_found_dir (const char *path,
dev_t path_dev);
#endif
void _g_local_file_info_get_parent_info (const char *dir,
GFileAttributeMatcher *attribute_matcher,
GLocalParentFileInfo *parent_info);