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).
This commit is contained in:
Руслан Ижбулатов 2018-08-08 22:26:41 +00:00
parent 256e741248
commit c6b4eff09e
4 changed files with 37 additions and 0 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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 */
/**

View File

@ -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;