1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
#![allow(deprecated)]
use crate::{FileAttributeMatcher, FileAttributeStatus, FileAttributeType, FileType, Icon};
use glib::{prelude::*, translate::*};
glib::wrapper! {
/// Stores information about a file system object referenced by a [`File`][crate::File].
///
/// Functionality for manipulating basic metadata for files. `GFileInfo`
/// implements methods for getting information that all files should
/// contain, and allows for manipulation of extended attributes.
///
/// See [file-attributes.html](file attributes) for more information on how GIO
/// handles file attributes.
///
/// To obtain a `GFileInfo` for a [`File`][crate::File], use
/// [`FileExt::query_info()`][crate::prelude::FileExt::query_info()] (or its async variant). To obtain a `GFileInfo`
/// for a file input or output stream, use [`FileInputStreamExt::query_info()`][crate::prelude::FileInputStreamExt::query_info()]
/// or [`FileOutputStreamExt::query_info()`][crate::prelude::FileOutputStreamExt::query_info()] (or their async variants).
///
/// To change the actual attributes of a file, you should then set the
/// attribute in the `GFileInfo` and call [`FileExt::set_attributes_from_info()`][crate::prelude::FileExt::set_attributes_from_info()]
/// or [`FileExt::set_attributes_async()`][crate::prelude::FileExt::set_attributes_async()] on a `GFile`.
///
/// However, not all attributes can be changed in the file. For instance,
/// the actual size of a file cannot be changed via [`set_size()`][Self::set_size()].
/// You may call [`FileExt::query_settable_attributes()`][crate::prelude::FileExt::query_settable_attributes()] and
/// [`FileExt::query_writable_namespaces()`][crate::prelude::FileExt::query_writable_namespaces()] to discover the settable attributes
/// of a particular file at runtime.
///
/// The direct accessors, such as [`name()`][Self::name()], are slightly more
/// optimized than the generic attribute accessors, such as
/// [`attribute_byte_string()`][Self::attribute_byte_string()].This optimization will matter
/// only if calling the API in a tight loop.
///
/// It is an error to call these accessors without specifying their required file
/// attributes when creating the `GFileInfo`. Use
/// [`has_attribute()`][Self::has_attribute()] or [`list_attributes()`][Self::list_attributes()]
/// to check what attributes are specified for a `GFileInfo`.
///
/// [`FileAttributeMatcher`][crate::FileAttributeMatcher] allows for searching through a `GFileInfo`
/// for attributes.
///
/// # Implements
///
/// [`trait@glib::ObjectExt`]
#[doc(alias = "GFileInfo")]
pub struct FileInfo(Object<ffi::GFileInfo, ffi::GFileInfoClass>);
match fn {
type_ => || ffi::g_file_info_get_type(),
}
}
impl FileInfo {
/// Creates a new file info structure.
///
/// # Returns
///
/// a #GFileInfo.
#[doc(alias = "g_file_info_new")]
pub fn new() -> FileInfo {
unsafe { from_glib_full(ffi::g_file_info_new()) }
}
/// Clears the status information from @self.
#[doc(alias = "g_file_info_clear_status")]
pub fn clear_status(&self) {
unsafe {
ffi::g_file_info_clear_status(self.to_glib_none().0);
}
}
/// First clears all of the [GFileAttribute][gio-GFileAttribute] of @dest_info,
/// and then copies all of the file attributes from @self to @dest_info.
/// ## `dest_info`
/// destination to copy attributes to.
#[doc(alias = "g_file_info_copy_into")]
pub fn copy_into(&self, dest_info: &FileInfo) {
unsafe {
ffi::g_file_info_copy_into(self.to_glib_none().0, dest_info.to_glib_none().0);
}
}
/// Duplicates a file info structure.
///
/// # Returns
///
/// a duplicate #GFileInfo of @self.
#[doc(alias = "g_file_info_dup")]
#[must_use]
pub fn dup(&self) -> FileInfo {
unsafe { from_glib_full(ffi::g_file_info_dup(self.to_glib_none().0)) }
}
/// Gets the access time of the current @self and returns it as a
/// #GDateTime.
///
/// It is an error to call this if the #GFileInfo does not contain
/// [`FILE_ATTRIBUTE_TIME_ACCESS`][crate::FILE_ATTRIBUTE_TIME_ACCESS]. If [`FILE_ATTRIBUTE_TIME_ACCESS_USEC`][crate::FILE_ATTRIBUTE_TIME_ACCESS_USEC] is
/// provided, the resulting #GDateTime will additionally have microsecond
/// precision.
///
/// If nanosecond precision is needed, [`FILE_ATTRIBUTE_TIME_ACCESS_NSEC`][crate::FILE_ATTRIBUTE_TIME_ACCESS_NSEC] must
/// be queried separately using g_file_info_get_attribute_uint32().
///
/// # Returns
///
/// access time, or [`None`] if unknown
#[cfg(feature = "v2_70")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))]
#[doc(alias = "g_file_info_get_access_date_time")]
#[doc(alias = "get_access_date_time")]
pub fn access_date_time(&self) -> Option<glib::DateTime> {
unsafe { from_glib_full(ffi::g_file_info_get_access_date_time(self.to_glib_none().0)) }
}
/// Gets the value of an attribute, formatted as a string.
/// This escapes things as needed to make the string valid
/// UTF-8.
/// ## `attribute`
/// a file attribute key.
///
/// # Returns
///
/// a UTF-8 string associated with the given @attribute, or
/// [`None`] if the attribute wasn’t set.
/// When you're done with the string it must be freed with g_free().
#[doc(alias = "g_file_info_get_attribute_as_string")]
#[doc(alias = "get_attribute_as_string")]
pub fn attribute_as_string(&self, attribute: &str) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::g_file_info_get_attribute_as_string(
self.to_glib_none().0,
attribute.to_glib_none().0,
))
}
}
/// Gets the value of a boolean attribute. If the attribute does not
/// contain a boolean value, [`false`] will be returned.
/// ## `attribute`
/// a file attribute key.
///
/// # Returns
///
/// the boolean value contained within the attribute.
#[doc(alias = "g_file_info_get_attribute_boolean")]
#[doc(alias = "get_attribute_boolean")]
pub fn boolean(&self, attribute: &str) -> bool {
unsafe {
from_glib(ffi::g_file_info_get_attribute_boolean(
self.to_glib_none().0,
attribute.to_glib_none().0,
))
}
}
/// Gets the value of a byte string attribute. If the attribute does
/// not contain a byte string, [`None`] will be returned.
/// ## `attribute`
/// a file attribute key.
///
/// # Returns
///
/// the contents of the @attribute value as a byte string, or
/// [`None`] otherwise.
#[doc(alias = "g_file_info_get_attribute_byte_string")]
#[doc(alias = "get_attribute_byte_string")]
pub fn attribute_byte_string(&self, attribute: &str) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::g_file_info_get_attribute_byte_string(
self.to_glib_none().0,
attribute.to_glib_none().0,
))
}
}
//#[doc(alias = "g_file_info_get_attribute_data")]
//#[doc(alias = "get_attribute_data")]
//pub fn attribute_data(&self, attribute: &str, value_pp: /*Unimplemented*/&mut Basic: Pointer) -> Option<(FileAttributeType, FileAttributeStatus)> {
// unsafe { TODO: call ffi:g_file_info_get_attribute_data() }
//}
/// Gets the value of a byte string attribute as a file path.
///
/// If the attribute does not contain a byte string, `NULL` will be returned.
///
/// This function is meant to be used by language bindings that have specific
/// handling for Unix paths.
/// ## `attribute`
/// a file attribute key.
///
/// # Returns
///
/// the contents of the @attribute value as
/// a file path, or [`None`] otherwise.
#[cfg(feature = "v2_78")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_78")))]
#[doc(alias = "g_file_info_get_attribute_file_path")]
#[doc(alias = "get_attribute_file_path")]
pub fn attribute_file_path(&self, attribute: &str) -> Option<std::path::PathBuf> {
unsafe {
from_glib_none(ffi::g_file_info_get_attribute_file_path(
self.to_glib_none().0,
attribute.to_glib_none().0,
))
}
}
/// Gets a signed 32-bit integer contained within the attribute. If the
/// attribute does not contain a signed 32-bit integer, or is invalid,
/// 0 will be returned.
/// ## `attribute`
/// a file attribute key.
///
/// # Returns
///
/// a signed 32-bit integer from the attribute.
#[doc(alias = "g_file_info_get_attribute_int32")]
#[doc(alias = "get_attribute_int32")]
pub fn attribute_int32(&self, attribute: &str) -> i32 {
unsafe {
ffi::g_file_info_get_attribute_int32(self.to_glib_none().0, attribute.to_glib_none().0)
}
}
/// Gets a signed 64-bit integer contained within the attribute. If the
/// attribute does not contain a signed 64-bit integer, or is invalid,
/// 0 will be returned.
/// ## `attribute`
/// a file attribute key.
///
/// # Returns
///
/// a signed 64-bit integer from the attribute.
#[doc(alias = "g_file_info_get_attribute_int64")]
#[doc(alias = "get_attribute_int64")]
pub fn attribute_int64(&self, attribute: &str) -> i64 {
unsafe {
ffi::g_file_info_get_attribute_int64(self.to_glib_none().0, attribute.to_glib_none().0)
}
}
/// Gets the value of a #GObject attribute. If the attribute does
/// not contain a #GObject, [`None`] will be returned.
/// ## `attribute`
/// a file attribute key.
///
/// # Returns
///
/// a #GObject associated with the given @attribute,
/// or [`None`] otherwise.
#[doc(alias = "g_file_info_get_attribute_object")]
#[doc(alias = "get_attribute_object")]
pub fn attribute_object(&self, attribute: &str) -> Option<glib::Object> {
unsafe {
from_glib_none(ffi::g_file_info_get_attribute_object(
self.to_glib_none().0,
attribute.to_glib_none().0,
))
}
}
/// Gets the attribute status for an attribute key.
/// ## `attribute`
/// a file attribute key
///
/// # Returns
///
/// a #GFileAttributeStatus for the given @attribute, or
/// [`FileAttributeStatus::Unset`][crate::FileAttributeStatus::Unset] if the key is invalid.
#[doc(alias = "g_file_info_get_attribute_status")]
#[doc(alias = "get_attribute_status")]
pub fn attribute_status(&self, attribute: &str) -> FileAttributeStatus {
unsafe {
from_glib(ffi::g_file_info_get_attribute_status(
self.to_glib_none().0,
attribute.to_glib_none().0,
))
}
}
/// Gets the value of a string attribute. If the attribute does
/// not contain a string, [`None`] will be returned.
/// ## `attribute`
/// a file attribute key.
///
/// # Returns
///
/// the contents of the @attribute value as a UTF-8 string,
/// or [`None`] otherwise.
#[doc(alias = "g_file_info_get_attribute_string")]
#[doc(alias = "get_attribute_string")]
pub fn attribute_string(&self, attribute: &str) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::g_file_info_get_attribute_string(
self.to_glib_none().0,
attribute.to_glib_none().0,
))
}
}
/// Gets the attribute type for an attribute key.
/// ## `attribute`
/// a file attribute key.
///
/// # Returns
///
/// a #GFileAttributeType for the given @attribute, or
/// [`FileAttributeType::Invalid`][crate::FileAttributeType::Invalid] if the key is not set.
#[doc(alias = "g_file_info_get_attribute_type")]
#[doc(alias = "get_attribute_type")]
pub fn attribute_type(&self, attribute: &str) -> FileAttributeType {
unsafe {
from_glib(ffi::g_file_info_get_attribute_type(
self.to_glib_none().0,
attribute.to_glib_none().0,
))
}
}
/// Gets an unsigned 32-bit integer contained within the attribute. If the
/// attribute does not contain an unsigned 32-bit integer, or is invalid,
/// 0 will be returned.
/// ## `attribute`
/// a file attribute key.
///
/// # Returns
///
/// an unsigned 32-bit integer from the attribute.
#[doc(alias = "g_file_info_get_attribute_uint32")]
#[doc(alias = "get_attribute_uint32")]
pub fn attribute_uint32(&self, attribute: &str) -> u32 {
unsafe {
ffi::g_file_info_get_attribute_uint32(self.to_glib_none().0, attribute.to_glib_none().0)
}
}
/// Gets a unsigned 64-bit integer contained within the attribute. If the
/// attribute does not contain an unsigned 64-bit integer, or is invalid,
/// 0 will be returned.
/// ## `attribute`
/// a file attribute key.
///
/// # Returns
///
/// a unsigned 64-bit integer from the attribute.
#[doc(alias = "g_file_info_get_attribute_uint64")]
#[doc(alias = "get_attribute_uint64")]
pub fn attribute_uint64(&self, attribute: &str) -> u64 {
unsafe {
ffi::g_file_info_get_attribute_uint64(self.to_glib_none().0, attribute.to_glib_none().0)
}
}
/// Gets the file's content type.
///
/// It is an error to call this if the #GFileInfo does not contain
/// [`FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE`][crate::FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE].
///
/// # Returns
///
/// a string containing the file's content type,
/// or [`None`] if unknown.
#[doc(alias = "g_file_info_get_content_type")]
#[doc(alias = "get_content_type")]
pub fn content_type(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::g_file_info_get_content_type(self.to_glib_none().0)) }
}
/// Gets the creation time of the current @self and returns it as a
/// #GDateTime.
///
/// It is an error to call this if the #GFileInfo does not contain
/// [`FILE_ATTRIBUTE_TIME_CREATED`][crate::FILE_ATTRIBUTE_TIME_CREATED]. If [`FILE_ATTRIBUTE_TIME_CREATED_USEC`][crate::FILE_ATTRIBUTE_TIME_CREATED_USEC] is
/// provided, the resulting #GDateTime will additionally have microsecond
/// precision.
///
/// If nanosecond precision is needed, [`FILE_ATTRIBUTE_TIME_CREATED_NSEC`][crate::FILE_ATTRIBUTE_TIME_CREATED_NSEC] must
/// be queried separately using g_file_info_get_attribute_uint32().
///
/// # Returns
///
/// creation time, or [`None`] if unknown
#[cfg(feature = "v2_70")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))]
#[doc(alias = "g_file_info_get_creation_date_time")]
#[doc(alias = "get_creation_date_time")]
pub fn creation_date_time(&self) -> Option<glib::DateTime> {
unsafe {
from_glib_full(ffi::g_file_info_get_creation_date_time(
self.to_glib_none().0,
))
}
}
/// Returns the #GDateTime representing the deletion date of the file, as
/// available in [`FILE_ATTRIBUTE_TRASH_DELETION_DATE`][crate::FILE_ATTRIBUTE_TRASH_DELETION_DATE]. If the
/// [`FILE_ATTRIBUTE_TRASH_DELETION_DATE`][crate::FILE_ATTRIBUTE_TRASH_DELETION_DATE] attribute is unset, [`None`] is returned.
///
/// # Returns
///
/// a #GDateTime, or [`None`].
#[doc(alias = "g_file_info_get_deletion_date")]
#[doc(alias = "get_deletion_date")]
pub fn deletion_date(&self) -> Option<glib::DateTime> {
unsafe { from_glib_full(ffi::g_file_info_get_deletion_date(self.to_glib_none().0)) }
}
/// Gets a display name for a file. This is guaranteed to always be set.
///
/// It is an error to call this if the #GFileInfo does not contain
/// [`FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME`][crate::FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME].
///
/// # Returns
///
/// a string containing the display name.
#[doc(alias = "g_file_info_get_display_name")]
#[doc(alias = "get_display_name")]
pub fn display_name(&self) -> glib::GString {
unsafe { from_glib_none(ffi::g_file_info_get_display_name(self.to_glib_none().0)) }
}
/// Gets the edit name for a file.
///
/// It is an error to call this if the #GFileInfo does not contain
/// [`FILE_ATTRIBUTE_STANDARD_EDIT_NAME`][crate::FILE_ATTRIBUTE_STANDARD_EDIT_NAME].
///
/// # Returns
///
/// a string containing the edit name.
#[doc(alias = "g_file_info_get_edit_name")]
#[doc(alias = "get_edit_name")]
pub fn edit_name(&self) -> glib::GString {
unsafe { from_glib_none(ffi::g_file_info_get_edit_name(self.to_glib_none().0)) }
}
/// Gets the [entity tag](iface.File.html#entity-tags) for a given
/// #GFileInfo. See [`FILE_ATTRIBUTE_ETAG_VALUE`][crate::FILE_ATTRIBUTE_ETAG_VALUE].
///
/// It is an error to call this if the #GFileInfo does not contain
/// [`FILE_ATTRIBUTE_ETAG_VALUE`][crate::FILE_ATTRIBUTE_ETAG_VALUE].
///
/// # Returns
///
/// a string containing the value of the "etag:value" attribute.
#[doc(alias = "g_file_info_get_etag")]
#[doc(alias = "get_etag")]
pub fn etag(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::g_file_info_get_etag(self.to_glib_none().0)) }
}
/// Gets a file's type (whether it is a regular file, symlink, etc).
/// This is different from the file's content type, see g_file_info_get_content_type().
///
/// It is an error to call this if the #GFileInfo does not contain
/// [`FILE_ATTRIBUTE_STANDARD_TYPE`][crate::FILE_ATTRIBUTE_STANDARD_TYPE].
///
/// # Returns
///
/// a #GFileType for the given file.
#[doc(alias = "g_file_info_get_file_type")]
#[doc(alias = "get_file_type")]
pub fn file_type(&self) -> FileType {
unsafe { from_glib(ffi::g_file_info_get_file_type(self.to_glib_none().0)) }
}
/// Gets the icon for a file.
///
/// It is an error to call this if the #GFileInfo does not contain
/// [`FILE_ATTRIBUTE_STANDARD_ICON`][crate::FILE_ATTRIBUTE_STANDARD_ICON].
///
/// # Returns
///
/// #GIcon for the given @self.
#[doc(alias = "g_file_info_get_icon")]
#[doc(alias = "get_icon")]
pub fn icon(&self) -> Option<Icon> {
unsafe { from_glib_none(ffi::g_file_info_get_icon(self.to_glib_none().0)) }
}
/// Checks if a file is a backup file.
///
/// It is an error to call this if the #GFileInfo does not contain
/// [`FILE_ATTRIBUTE_STANDARD_IS_BACKUP`][crate::FILE_ATTRIBUTE_STANDARD_IS_BACKUP].
///
/// # Returns
///
/// [`true`] if file is a backup file, [`false`] otherwise.
#[doc(alias = "g_file_info_get_is_backup")]
#[doc(alias = "get_is_backup")]
pub fn is_backup(&self) -> bool {
unsafe { from_glib(ffi::g_file_info_get_is_backup(self.to_glib_none().0)) }
}
/// Checks if a file is hidden.
///
/// It is an error to call this if the #GFileInfo does not contain
/// [`FILE_ATTRIBUTE_STANDARD_IS_HIDDEN`][crate::FILE_ATTRIBUTE_STANDARD_IS_HIDDEN].
///
/// # Returns
///
/// [`true`] if the file is a hidden file, [`false`] otherwise.
#[doc(alias = "g_file_info_get_is_hidden")]
#[doc(alias = "get_is_hidden")]
pub fn is_hidden(&self) -> bool {
unsafe { from_glib(ffi::g_file_info_get_is_hidden(self.to_glib_none().0)) }
}
/// Checks if a file is a symlink.
///
/// It is an error to call this if the #GFileInfo does not contain
/// [`FILE_ATTRIBUTE_STANDARD_IS_SYMLINK`][crate::FILE_ATTRIBUTE_STANDARD_IS_SYMLINK].
///
/// # Returns
///
/// [`true`] if the given @self is a symlink.
#[doc(alias = "g_file_info_get_is_symlink")]
#[doc(alias = "get_is_symlink")]
pub fn is_symlink(&self) -> bool {
unsafe { from_glib(ffi::g_file_info_get_is_symlink(self.to_glib_none().0)) }
}
/// Gets the modification time of the current @self and returns it as a
/// #GDateTime.
///
/// It is an error to call this if the #GFileInfo does not contain
/// [`FILE_ATTRIBUTE_TIME_MODIFIED`][crate::FILE_ATTRIBUTE_TIME_MODIFIED]. If [`FILE_ATTRIBUTE_TIME_MODIFIED_USEC`][crate::FILE_ATTRIBUTE_TIME_MODIFIED_USEC] is
/// provided, the resulting #GDateTime will additionally have microsecond
/// precision.
///
/// If nanosecond precision is needed, [`FILE_ATTRIBUTE_TIME_MODIFIED_NSEC`][crate::FILE_ATTRIBUTE_TIME_MODIFIED_NSEC] must
/// be queried separately using g_file_info_get_attribute_uint32().
///
/// # Returns
///
/// modification time, or [`None`] if unknown
#[cfg(feature = "v2_62")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_62")))]
#[doc(alias = "g_file_info_get_modification_date_time")]
#[doc(alias = "get_modification_date_time")]
pub fn modification_date_time(&self) -> Option<glib::DateTime> {
unsafe {
from_glib_full(ffi::g_file_info_get_modification_date_time(
self.to_glib_none().0,
))
}
}
/// Gets the name for a file. This is guaranteed to always be set.
///
/// It is an error to call this if the #GFileInfo does not contain
/// [`FILE_ATTRIBUTE_STANDARD_NAME`][crate::FILE_ATTRIBUTE_STANDARD_NAME].
///
/// # Returns
///
/// a string containing the file name.
#[doc(alias = "g_file_info_get_name")]
#[doc(alias = "get_name")]
pub fn name(&self) -> std::path::PathBuf {
unsafe { from_glib_none(ffi::g_file_info_get_name(self.to_glib_none().0)) }
}
/// Gets the file's size (in bytes). The size is retrieved through the value of
/// the [`FILE_ATTRIBUTE_STANDARD_SIZE`][crate::FILE_ATTRIBUTE_STANDARD_SIZE] attribute and is converted
/// from #guint64 to #goffset before returning the result.
///
/// It is an error to call this if the #GFileInfo does not contain
/// [`FILE_ATTRIBUTE_STANDARD_SIZE`][crate::FILE_ATTRIBUTE_STANDARD_SIZE].
///
/// # Returns
///
/// a #goffset containing the file's size (in bytes).
#[doc(alias = "g_file_info_get_size")]
#[doc(alias = "get_size")]
pub fn size(&self) -> i64 {
unsafe { ffi::g_file_info_get_size(self.to_glib_none().0) }
}
/// Gets the value of the sort_order attribute from the #GFileInfo.
/// See [`FILE_ATTRIBUTE_STANDARD_SORT_ORDER`][crate::FILE_ATTRIBUTE_STANDARD_SORT_ORDER].
///
/// It is an error to call this if the #GFileInfo does not contain
/// [`FILE_ATTRIBUTE_STANDARD_SORT_ORDER`][crate::FILE_ATTRIBUTE_STANDARD_SORT_ORDER].
///
/// # Returns
///
/// a #gint32 containing the value of the "standard::sort_order" attribute.
#[doc(alias = "g_file_info_get_sort_order")]
#[doc(alias = "get_sort_order")]
pub fn sort_order(&self) -> i32 {
unsafe { ffi::g_file_info_get_sort_order(self.to_glib_none().0) }
}
/// Gets the symbolic icon for a file.
///
/// It is an error to call this if the #GFileInfo does not contain
/// [`FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON`][crate::FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON].
///
/// # Returns
///
/// #GIcon for the given @self.
#[doc(alias = "g_file_info_get_symbolic_icon")]
#[doc(alias = "get_symbolic_icon")]
pub fn symbolic_icon(&self) -> Option<Icon> {
unsafe { from_glib_none(ffi::g_file_info_get_symbolic_icon(self.to_glib_none().0)) }
}
/// Gets the symlink target for a given #GFileInfo.
///
/// It is an error to call this if the #GFileInfo does not contain
/// [`FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET`][crate::FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET].
///
/// # Returns
///
/// a string containing the symlink target.
#[doc(alias = "g_file_info_get_symlink_target")]
#[doc(alias = "get_symlink_target")]
pub fn symlink_target(&self) -> Option<std::path::PathBuf> {
unsafe { from_glib_none(ffi::g_file_info_get_symlink_target(self.to_glib_none().0)) }
}
/// Checks if a file info structure has an attribute named @attribute.
/// ## `attribute`
/// a file attribute key.
///
/// # Returns
///
/// [`true`] if @self has an attribute named @attribute,
/// [`false`] otherwise.
#[doc(alias = "g_file_info_has_attribute")]
pub fn has_attribute(&self, attribute: &str) -> bool {
unsafe {
from_glib(ffi::g_file_info_has_attribute(
self.to_glib_none().0,
attribute.to_glib_none().0,
))
}
}
/// Checks if a file info structure has an attribute in the
/// specified @name_space.
/// ## `name_space`
/// a file attribute namespace.
///
/// # Returns
///
/// [`true`] if @self has an attribute in @name_space,
/// [`false`] otherwise.
#[doc(alias = "g_file_info_has_namespace")]
pub fn has_namespace(&self, name_space: &str) -> bool {
unsafe {
from_glib(ffi::g_file_info_has_namespace(
self.to_glib_none().0,
name_space.to_glib_none().0,
))
}
}
/// Lists the file info structure's attributes.
/// ## `name_space`
/// a file attribute key's namespace, or [`None`] to list
/// all attributes.
///
/// # Returns
///
/// a
/// null-terminated array of strings of all of the possible attribute
/// types for the given @name_space, or [`None`] on error.
#[doc(alias = "g_file_info_list_attributes")]
pub fn list_attributes(&self, name_space: Option<&str>) -> Vec<glib::GString> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::g_file_info_list_attributes(
self.to_glib_none().0,
name_space.to_glib_none().0,
))
}
}
/// Removes all cases of @attribute from @self if it exists.
/// ## `attribute`
/// a file attribute key.
#[doc(alias = "g_file_info_remove_attribute")]
pub fn remove_attribute(&self, attribute: &str) {
unsafe {
ffi::g_file_info_remove_attribute(self.to_glib_none().0, attribute.to_glib_none().0);
}
}
/// Sets the [`FILE_ATTRIBUTE_TIME_ACCESS`][crate::FILE_ATTRIBUTE_TIME_ACCESS] and
/// [`FILE_ATTRIBUTE_TIME_ACCESS_USEC`][crate::FILE_ATTRIBUTE_TIME_ACCESS_USEC] attributes in the file info to the
/// given date/time value.
///
/// [`FILE_ATTRIBUTE_TIME_ACCESS_NSEC`][crate::FILE_ATTRIBUTE_TIME_ACCESS_NSEC] will be cleared.
/// ## `atime`
/// a #GDateTime.
#[cfg(feature = "v2_70")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))]
#[doc(alias = "g_file_info_set_access_date_time")]
pub fn set_access_date_time(&self, atime: &glib::DateTime) {
unsafe {
ffi::g_file_info_set_access_date_time(self.to_glib_none().0, atime.to_glib_none().0);
}
}
//#[doc(alias = "g_file_info_set_attribute")]
//pub fn set_attribute(&self, attribute: &str, type_: FileAttributeType, value_p: /*Unimplemented*/Basic: Pointer) {
// unsafe { TODO: call ffi:g_file_info_set_attribute() }
//}
/// Sets the @attribute to contain the given @attr_value,
/// if possible.
/// ## `attribute`
/// a file attribute key.
/// ## `attr_value`
/// a boolean value.
#[doc(alias = "g_file_info_set_attribute_boolean")]
pub fn set_attribute_boolean(&self, attribute: &str, attr_value: bool) {
unsafe {
ffi::g_file_info_set_attribute_boolean(
self.to_glib_none().0,
attribute.to_glib_none().0,
attr_value.into_glib(),
);
}
}
/// Sets the @attribute to contain the given @attr_value,
/// if possible.
/// ## `attribute`
/// a file attribute key.
/// ## `attr_value`
/// a byte string.
#[doc(alias = "g_file_info_set_attribute_byte_string")]
pub fn set_attribute_byte_string(&self, attribute: &str, attr_value: &str) {
unsafe {
ffi::g_file_info_set_attribute_byte_string(
self.to_glib_none().0,
attribute.to_glib_none().0,
attr_value.to_glib_none().0,
);
}
}
/// Sets the @attribute to contain the given @attr_value,
/// if possible.
///
/// This function is meant to be used by language bindings that have specific
/// handling for Unix paths.
/// ## `attribute`
/// a file attribute key.
/// ## `attr_value`
/// a file path.
#[cfg(feature = "v2_78")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_78")))]
#[doc(alias = "g_file_info_set_attribute_file_path")]
pub fn set_attribute_file_path(
&self,
attribute: &str,
attr_value: impl AsRef<std::path::Path>,
) {
unsafe {
ffi::g_file_info_set_attribute_file_path(
self.to_glib_none().0,
attribute.to_glib_none().0,
attr_value.as_ref().to_glib_none().0,
);
}
}
/// Sets the @attribute to contain the given @attr_value,
/// if possible.
/// ## `attribute`
/// a file attribute key.
/// ## `attr_value`
/// a signed 32-bit integer
#[doc(alias = "g_file_info_set_attribute_int32")]
pub fn set_attribute_int32(&self, attribute: &str, attr_value: i32) {
unsafe {
ffi::g_file_info_set_attribute_int32(
self.to_glib_none().0,
attribute.to_glib_none().0,
attr_value,
);
}
}
/// Sets the @attribute to contain the given @attr_value,
/// if possible.
/// ## `attribute`
/// attribute name to set.
/// ## `attr_value`
/// int64 value to set attribute to.
#[doc(alias = "g_file_info_set_attribute_int64")]
pub fn set_attribute_int64(&self, attribute: &str, attr_value: i64) {
unsafe {
ffi::g_file_info_set_attribute_int64(
self.to_glib_none().0,
attribute.to_glib_none().0,
attr_value,
);
}
}
/// Sets @mask on @self to match specific attribute types.
/// ## `mask`
/// a #GFileAttributeMatcher.
#[doc(alias = "g_file_info_set_attribute_mask")]
pub fn set_attribute_mask(&self, mask: &FileAttributeMatcher) {
unsafe {
ffi::g_file_info_set_attribute_mask(self.to_glib_none().0, mask.to_glib_none().0);
}
}
/// Sets the @attribute to contain the given @attr_value,
/// if possible.
/// ## `attribute`
/// a file attribute key.
/// ## `attr_value`
/// a #GObject.
#[doc(alias = "g_file_info_set_attribute_object")]
pub fn set_attribute_object(&self, attribute: &str, attr_value: &impl IsA<glib::Object>) {
unsafe {
ffi::g_file_info_set_attribute_object(
self.to_glib_none().0,
attribute.to_glib_none().0,
attr_value.as_ref().to_glib_none().0,
);
}
}
/// Sets the attribute status for an attribute key. This is only
/// needed by external code that implement g_file_set_attributes_from_info()
/// or similar functions.
///
/// The attribute must exist in @self for this to work. Otherwise [`false`]
/// is returned and @self is unchanged.
/// ## `attribute`
/// a file attribute key
/// ## `status`
/// a #GFileAttributeStatus
///
/// # Returns
///
/// [`true`] if the status was changed, [`false`] if the key was not set.
#[doc(alias = "g_file_info_set_attribute_status")]
pub fn set_attribute_status(&self, attribute: &str, status: FileAttributeStatus) -> bool {
unsafe {
from_glib(ffi::g_file_info_set_attribute_status(
self.to_glib_none().0,
attribute.to_glib_none().0,
status.into_glib(),
))
}
}
/// Sets the @attribute to contain the given @attr_value,
/// if possible.
/// ## `attribute`
/// a file attribute key.
/// ## `attr_value`
/// a UTF-8 string.
#[doc(alias = "g_file_info_set_attribute_string")]
pub fn set_attribute_string(&self, attribute: &str, attr_value: &str) {
unsafe {
ffi::g_file_info_set_attribute_string(
self.to_glib_none().0,
attribute.to_glib_none().0,
attr_value.to_glib_none().0,
);
}
}
/// Sets the @attribute to contain the given @attr_value,
/// if possible.
/// ## `attribute`
/// a file attribute key.
/// ## `attr_value`
/// an unsigned 32-bit integer.
#[doc(alias = "g_file_info_set_attribute_uint32")]
pub fn set_attribute_uint32(&self, attribute: &str, attr_value: u32) {
unsafe {
ffi::g_file_info_set_attribute_uint32(
self.to_glib_none().0,
attribute.to_glib_none().0,
attr_value,
);
}
}
/// Sets the @attribute to contain the given @attr_value,
/// if possible.
/// ## `attribute`
/// a file attribute key.
/// ## `attr_value`
/// an unsigned 64-bit integer.
#[doc(alias = "g_file_info_set_attribute_uint64")]
pub fn set_attribute_uint64(&self, attribute: &str, attr_value: u64) {
unsafe {
ffi::g_file_info_set_attribute_uint64(
self.to_glib_none().0,
attribute.to_glib_none().0,
attr_value,
);
}
}
/// Sets the content type attribute for a given #GFileInfo.
/// See [`FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE`][crate::FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE].
/// ## `content_type`
/// a content type. See [GContentType][gio-GContentType]
#[doc(alias = "g_file_info_set_content_type")]
pub fn set_content_type(&self, content_type: &str) {
unsafe {
ffi::g_file_info_set_content_type(self.to_glib_none().0, content_type.to_glib_none().0);
}
}
/// Sets the [`FILE_ATTRIBUTE_TIME_CREATED`][crate::FILE_ATTRIBUTE_TIME_CREATED] and
/// [`FILE_ATTRIBUTE_TIME_CREATED_USEC`][crate::FILE_ATTRIBUTE_TIME_CREATED_USEC] attributes in the file info to the
/// given date/time value.
///
/// [`FILE_ATTRIBUTE_TIME_CREATED_NSEC`][crate::FILE_ATTRIBUTE_TIME_CREATED_NSEC] will be cleared.
/// ## `creation_time`
/// a #GDateTime.
#[cfg(feature = "v2_70")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))]
#[doc(alias = "g_file_info_set_creation_date_time")]
pub fn set_creation_date_time(&self, creation_time: &glib::DateTime) {
unsafe {
ffi::g_file_info_set_creation_date_time(
self.to_glib_none().0,
creation_time.to_glib_none().0,
);
}
}
/// Sets the display name for the current #GFileInfo.
/// See [`FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME`][crate::FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME].
/// ## `display_name`
/// a string containing a display name.
#[doc(alias = "g_file_info_set_display_name")]
pub fn set_display_name(&self, display_name: &str) {
unsafe {
ffi::g_file_info_set_display_name(self.to_glib_none().0, display_name.to_glib_none().0);
}
}
/// Sets the edit name for the current file.
/// See [`FILE_ATTRIBUTE_STANDARD_EDIT_NAME`][crate::FILE_ATTRIBUTE_STANDARD_EDIT_NAME].
/// ## `edit_name`
/// a string containing an edit name.
#[doc(alias = "g_file_info_set_edit_name")]
pub fn set_edit_name(&self, edit_name: &str) {
unsafe {
ffi::g_file_info_set_edit_name(self.to_glib_none().0, edit_name.to_glib_none().0);
}
}
/// Sets the file type in a #GFileInfo to @type_.
/// See [`FILE_ATTRIBUTE_STANDARD_TYPE`][crate::FILE_ATTRIBUTE_STANDARD_TYPE].
/// ## `type_`
/// a #GFileType.
#[doc(alias = "g_file_info_set_file_type")]
pub fn set_file_type(&self, type_: FileType) {
unsafe {
ffi::g_file_info_set_file_type(self.to_glib_none().0, type_.into_glib());
}
}
/// Sets the icon for a given #GFileInfo.
/// See [`FILE_ATTRIBUTE_STANDARD_ICON`][crate::FILE_ATTRIBUTE_STANDARD_ICON].
/// ## `icon`
/// a #GIcon.
#[doc(alias = "g_file_info_set_icon")]
pub fn set_icon(&self, icon: &impl IsA<Icon>) {
unsafe {
ffi::g_file_info_set_icon(self.to_glib_none().0, icon.as_ref().to_glib_none().0);
}
}
/// Sets the "is_hidden" attribute in a #GFileInfo according to @is_hidden.
/// See [`FILE_ATTRIBUTE_STANDARD_IS_HIDDEN`][crate::FILE_ATTRIBUTE_STANDARD_IS_HIDDEN].
/// ## `is_hidden`
/// a #gboolean.
#[doc(alias = "g_file_info_set_is_hidden")]
pub fn set_is_hidden(&self, is_hidden: bool) {
unsafe {
ffi::g_file_info_set_is_hidden(self.to_glib_none().0, is_hidden.into_glib());
}
}
/// Sets the "is_symlink" attribute in a #GFileInfo according to @is_symlink.
/// See [`FILE_ATTRIBUTE_STANDARD_IS_SYMLINK`][crate::FILE_ATTRIBUTE_STANDARD_IS_SYMLINK].
/// ## `is_symlink`
/// a #gboolean.
#[doc(alias = "g_file_info_set_is_symlink")]
pub fn set_is_symlink(&self, is_symlink: bool) {
unsafe {
ffi::g_file_info_set_is_symlink(self.to_glib_none().0, is_symlink.into_glib());
}
}
/// Sets the [`FILE_ATTRIBUTE_TIME_MODIFIED`][crate::FILE_ATTRIBUTE_TIME_MODIFIED] and
/// [`FILE_ATTRIBUTE_TIME_MODIFIED_USEC`][crate::FILE_ATTRIBUTE_TIME_MODIFIED_USEC] attributes in the file info to the
/// given date/time value.
///
/// [`FILE_ATTRIBUTE_TIME_MODIFIED_NSEC`][crate::FILE_ATTRIBUTE_TIME_MODIFIED_NSEC] will be cleared.
/// ## `mtime`
/// a #GDateTime.
#[cfg(feature = "v2_62")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_62")))]
#[doc(alias = "g_file_info_set_modification_date_time")]
pub fn set_modification_date_time(&self, mtime: &glib::DateTime) {
unsafe {
ffi::g_file_info_set_modification_date_time(
self.to_glib_none().0,
mtime.to_glib_none().0,
);
}
}
/// Sets the name attribute for the current #GFileInfo.
/// See [`FILE_ATTRIBUTE_STANDARD_NAME`][crate::FILE_ATTRIBUTE_STANDARD_NAME].
/// ## `name`
/// a string containing a name.
#[doc(alias = "g_file_info_set_name")]
pub fn set_name(&self, name: impl AsRef<std::path::Path>) {
unsafe {
ffi::g_file_info_set_name(self.to_glib_none().0, name.as_ref().to_glib_none().0);
}
}
/// Sets the [`FILE_ATTRIBUTE_STANDARD_SIZE`][crate::FILE_ATTRIBUTE_STANDARD_SIZE] attribute in the file info
/// to the given size.
/// ## `size`
/// a #goffset containing the file's size.
#[doc(alias = "g_file_info_set_size")]
pub fn set_size(&self, size: i64) {
unsafe {
ffi::g_file_info_set_size(self.to_glib_none().0, size);
}
}
/// Sets the sort order attribute in the file info structure. See
/// [`FILE_ATTRIBUTE_STANDARD_SORT_ORDER`][crate::FILE_ATTRIBUTE_STANDARD_SORT_ORDER].
/// ## `sort_order`
/// a sort order integer.
#[doc(alias = "g_file_info_set_sort_order")]
pub fn set_sort_order(&self, sort_order: i32) {
unsafe {
ffi::g_file_info_set_sort_order(self.to_glib_none().0, sort_order);
}
}
/// Sets the symbolic icon for a given #GFileInfo.
/// See [`FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON`][crate::FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON].
/// ## `icon`
/// a #GIcon.
#[doc(alias = "g_file_info_set_symbolic_icon")]
pub fn set_symbolic_icon(&self, icon: &impl IsA<Icon>) {
unsafe {
ffi::g_file_info_set_symbolic_icon(
self.to_glib_none().0,
icon.as_ref().to_glib_none().0,
);
}
}
/// Sets the [`FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET`][crate::FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET] attribute in the file info
/// to the given symlink target.
/// ## `symlink_target`
/// a static string containing a path to a symlink target.
#[doc(alias = "g_file_info_set_symlink_target")]
pub fn set_symlink_target(&self, symlink_target: impl AsRef<std::path::Path>) {
unsafe {
ffi::g_file_info_set_symlink_target(
self.to_glib_none().0,
symlink_target.as_ref().to_glib_none().0,
);
}
}
/// Unsets a mask set by g_file_info_set_attribute_mask(), if one
/// is set.
#[doc(alias = "g_file_info_unset_attribute_mask")]
pub fn unset_attribute_mask(&self) {
unsafe {
ffi::g_file_info_unset_attribute_mask(self.to_glib_none().0);
}
}
}
impl Default for FileInfo {
fn default() -> Self {
Self::new()
}
}