14.9. 设置自定义的 GIO 元数据属性

此流程描述了如何设置自定义的元数据属性。

请注意,特定 gio 信息 调用和数据持久性在移动或重命名后差别。请注意 gio info 命令输出。

流程

  1. 创建一个空文件:

    $ touch /tmp/myfile
  2. 查看此文件的元数据:

    $ gio info -a 'metadata::*' /tmp/myfile
    uri: file:///tmp/myfile
    attributes:
  3. 将字符串设置为此文件:

    $ gio set -t string /tmp/myfile 'metadata::mynote' 'Please remember to delete this file!'
  4. 查看元数据:

    $ gio info -a 'metadata::*' /tmp/myfile
    uri: file:///tmp/myfile
    attributes:
      metadata::mynote: Please remember to delete this file!
  5. 将此文件移到新位置:

    $ gio move /tmp/myfile /tmp/newfile
  6. 查看元数据:

    $ gio info -a 'metadata::*' /tmp/newfile
    uri: file:///tmp/newfile
    attributes:
      metadata::mynote: Please remember to delete this file!

当您使用 GIO API 移动文件时,元数据将保持不变。

其它资源

  • The gio 手册页。