[glib/glib-2-58: 16/55] W32: new GFileInfo attributes
- From: Xavier Claessens <xclaesse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-58: 16/55] W32: new GFileInfo attributes
- Date: Fri, 19 Oct 2018 13:38:52 +0000 (UTC)
commit a2375b8929c70eb9cdb98e828643955c823be52d
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date: Wed Aug 8 22:26:41 2018 +0000
W32: new GFileInfo attributes
G_FILE_ATTRIBUTE_DOS_IS_MOUNTPOINT allows mountpoints
(NTFS reparse points with IO_REPARSE_TAG_MOUNT_POINT tag) to
be told apart from symlinks (NTFS reparse points with
IO_REPARSE_TAG_SYMLINK tag), even though both are reported
by glib as "symlinks".
G_FILE_ATTRIBUTE_DOS_REPARSE_POINT_TAG allows the exact
reparse tag value to be obtained by the user. This way
even more exotic reparse points can be identified and
handled by the user (glib itself currently has no code
to work with any reparse points that are not symlinks
or mountpoints).
gio/gfileinfo-priv.h | 2 ++
gio/gfileinfo.c | 2 ++
gio/gfileinfo.h | 27 +++++++++++++++++++++++++++
gio/glocalfileinfo.c | 6 ++++++
4 files changed, 37 insertions(+)
---
diff --git a/gio/gfileinfo-priv.h b/gio/gfileinfo-priv.h
index 201b8c946..e2bdaa33d 100644
--- a/gio/gfileinfo-priv.h
+++ b/gio/gfileinfo-priv.h
@@ -85,6 +85,8 @@
#define G_FILE_ATTRIBUTE_ID_UNIX_IS_MOUNTPOINT (7340032 + 10)
#define G_FILE_ATTRIBUTE_ID_DOS_IS_ARCHIVE (8388608 + 1)
#define G_FILE_ATTRIBUTE_ID_DOS_IS_SYSTEM (8388608 + 2)
+#define G_FILE_ATTRIBUTE_ID_DOS_IS_MOUNTPOINT (8388608 + 3)
+#define G_FILE_ATTRIBUTE_ID_DOS_REPARSE_POINT_TAG (8388608 + 4)
#define G_FILE_ATTRIBUTE_ID_OWNER_USER (9437184 + 1)
#define G_FILE_ATTRIBUTE_ID_OWNER_USER_REAL (9437184 + 2)
#define G_FILE_ATTRIBUTE_ID_OWNER_GROUP (9437184 + 3)
diff --git a/gio/gfileinfo.c b/gio/gfileinfo.c
index a595c6f4a..fa53a9c49 100644
--- a/gio/gfileinfo.c
+++ b/gio/gfileinfo.c
@@ -245,6 +245,8 @@ ensure_attribute_hash (void)
REGISTER_ATTRIBUTE (UNIX_IS_MOUNTPOINT);
REGISTER_ATTRIBUTE (DOS_IS_ARCHIVE);
REGISTER_ATTRIBUTE (DOS_IS_SYSTEM);
+ REGISTER_ATTRIBUTE (DOS_IS_MOUNTPOINT);
+ REGISTER_ATTRIBUTE (DOS_REPARSE_POINT_TAG);
REGISTER_ATTRIBUTE (OWNER_USER);
REGISTER_ATTRIBUTE (OWNER_USER_REAL);
REGISTER_ATTRIBUTE (OWNER_GROUP);
diff --git a/gio/gfileinfo.h b/gio/gfileinfo.h
index 8416b4fad..2ca623c3a 100644
--- a/gio/gfileinfo.h
+++ b/gio/gfileinfo.h
@@ -672,6 +672,33 @@ typedef struct _GFileInfoClass GFileInfoClass;
**/
#define G_FILE_ATTRIBUTE_DOS_IS_SYSTEM "dos::is-system" /* boolean */
+/**
+ * G_FILE_ATTRIBUTE_DOS_IS_MOUNTPOINT:
+ *
+ * A key in the "dos" namespace for checking if the file is a NTFS mount point
+ * (a volume mount or a junction point).
+ * This attribute is %TRUE if file is a reparse point of type
+ * [IO_REPARSE_TAG_MOUNT_POINT](https://msdn.microsoft.com/en-us/library/dd541667.aspx).
+ * This attribute is only available for DOS file systems.
+ * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN.
+ *
+ * Since: 2.60
+ **/
+#define G_FILE_ATTRIBUTE_DOS_IS_MOUNTPOINT "dos::is-mountpoint" /* boolean */
+
+/**
+ * G_FILE_ATTRIBUTE_DOS_REPARSE_POINT_TAG:
+ *
+ * A key in the "dos" namespace for getting the file NTFS reparse tag.
+ * This value is 0 for files that are not reparse points.
+ * See the [Reparse Tags](https://msdn.microsoft.com/en-us/library/dd541667.aspx)
+ * page for possible reparse tag values. Corresponding #GFileAttributeType
+ * is %G_FILE_ATTRIBUTE_TYPE_UINT32.
+ *
+ * Since: 2.60
+ **/
+#define G_FILE_ATTRIBUTE_DOS_REPARSE_POINT_TAG "dos::reparse-point-tag" /* uint32 */
+
/* Owner attributes */
/**
diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c
index 58802fd43..ed7e99400 100644
--- a/gio/glocalfileinfo.c
+++ b/gio/glocalfileinfo.c
@@ -1867,6 +1867,12 @@ _g_local_file_info_get (const char *basename,
if (statbuf.attributes & FILE_ATTRIBUTE_SYSTEM)
_g_file_info_set_attribute_boolean_by_id (info, G_FILE_ATTRIBUTE_ID_DOS_IS_SYSTEM, TRUE);
+
+ if (statbuf.reparse_tag == IO_REPARSE_TAG_MOUNT_POINT)
+ _g_file_info_set_attribute_boolean_by_id (info, G_FILE_ATTRIBUTE_ID_DOS_IS_MOUNTPOINT, TRUE);
+
+ if (statbuf.reparse_tag != 0)
+ _g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_DOS_REPARSE_POINT_TAG,
statbuf.reparse_tag);
#endif
symlink_target = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]