gio/auto/
file_info.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use gio_sys;
6use glib;
7use glib::object::IsA;
8use glib::translate::*;
9use glib::GString;
10use std;
11use std::fmt;
12use FileAttributeMatcher;
13use FileAttributeStatus;
14use FileAttributeType;
15use FileType;
16use Icon;
17
18glib_wrapper! {
19    pub struct FileInfo(Object<gio_sys::GFileInfo, gio_sys::GFileInfoClass, FileInfoClass>);
20
21    match fn {
22        get_type => || gio_sys::g_file_info_get_type(),
23    }
24}
25
26impl FileInfo {
27    pub fn new() -> FileInfo {
28        unsafe { from_glib_full(gio_sys::g_file_info_new()) }
29    }
30
31    pub fn clear_status(&self) {
32        unsafe {
33            gio_sys::g_file_info_clear_status(self.to_glib_none().0);
34        }
35    }
36
37    pub fn copy_into(&self, dest_info: &FileInfo) {
38        unsafe {
39            gio_sys::g_file_info_copy_into(self.to_glib_none().0, dest_info.to_glib_none().0);
40        }
41    }
42
43    pub fn dup(&self) -> Option<FileInfo> {
44        unsafe { from_glib_full(gio_sys::g_file_info_dup(self.to_glib_none().0)) }
45    }
46
47    pub fn get_attribute_as_string(&self, attribute: &str) -> Option<GString> {
48        unsafe {
49            from_glib_full(gio_sys::g_file_info_get_attribute_as_string(
50                self.to_glib_none().0,
51                attribute.to_glib_none().0,
52            ))
53        }
54    }
55
56    pub fn get_attribute_boolean(&self, attribute: &str) -> bool {
57        unsafe {
58            from_glib(gio_sys::g_file_info_get_attribute_boolean(
59                self.to_glib_none().0,
60                attribute.to_glib_none().0,
61            ))
62        }
63    }
64
65    pub fn get_attribute_byte_string(&self, attribute: &str) -> Option<GString> {
66        unsafe {
67            from_glib_none(gio_sys::g_file_info_get_attribute_byte_string(
68                self.to_glib_none().0,
69                attribute.to_glib_none().0,
70            ))
71        }
72    }
73
74    //pub fn get_attribute_data(&self, attribute: &str, value_pp: /*Unimplemented*/&mut Fundamental: Pointer) -> Option<(FileAttributeType, FileAttributeStatus)> {
75    //    unsafe { TODO: call gio_sys:g_file_info_get_attribute_data() }
76    //}
77
78    pub fn get_attribute_int32(&self, attribute: &str) -> i32 {
79        unsafe {
80            gio_sys::g_file_info_get_attribute_int32(
81                self.to_glib_none().0,
82                attribute.to_glib_none().0,
83            )
84        }
85    }
86
87    pub fn get_attribute_int64(&self, attribute: &str) -> i64 {
88        unsafe {
89            gio_sys::g_file_info_get_attribute_int64(
90                self.to_glib_none().0,
91                attribute.to_glib_none().0,
92            )
93        }
94    }
95
96    pub fn get_attribute_object(&self, attribute: &str) -> Option<glib::Object> {
97        unsafe {
98            from_glib_none(gio_sys::g_file_info_get_attribute_object(
99                self.to_glib_none().0,
100                attribute.to_glib_none().0,
101            ))
102        }
103    }
104
105    pub fn get_attribute_status(&self, attribute: &str) -> FileAttributeStatus {
106        unsafe {
107            from_glib(gio_sys::g_file_info_get_attribute_status(
108                self.to_glib_none().0,
109                attribute.to_glib_none().0,
110            ))
111        }
112    }
113
114    pub fn get_attribute_string(&self, attribute: &str) -> Option<GString> {
115        unsafe {
116            from_glib_none(gio_sys::g_file_info_get_attribute_string(
117                self.to_glib_none().0,
118                attribute.to_glib_none().0,
119            ))
120        }
121    }
122
123    pub fn get_attribute_stringv(&self, attribute: &str) -> Vec<GString> {
124        unsafe {
125            FromGlibPtrContainer::from_glib_none(gio_sys::g_file_info_get_attribute_stringv(
126                self.to_glib_none().0,
127                attribute.to_glib_none().0,
128            ))
129        }
130    }
131
132    pub fn get_attribute_type(&self, attribute: &str) -> FileAttributeType {
133        unsafe {
134            from_glib(gio_sys::g_file_info_get_attribute_type(
135                self.to_glib_none().0,
136                attribute.to_glib_none().0,
137            ))
138        }
139    }
140
141    pub fn get_attribute_uint32(&self, attribute: &str) -> u32 {
142        unsafe {
143            gio_sys::g_file_info_get_attribute_uint32(
144                self.to_glib_none().0,
145                attribute.to_glib_none().0,
146            )
147        }
148    }
149
150    pub fn get_attribute_uint64(&self, attribute: &str) -> u64 {
151        unsafe {
152            gio_sys::g_file_info_get_attribute_uint64(
153                self.to_glib_none().0,
154                attribute.to_glib_none().0,
155            )
156        }
157    }
158
159    pub fn get_content_type(&self) -> Option<GString> {
160        unsafe { from_glib_none(gio_sys::g_file_info_get_content_type(self.to_glib_none().0)) }
161    }
162
163    pub fn get_deletion_date(&self) -> Option<glib::DateTime> {
164        unsafe {
165            from_glib_full(gio_sys::g_file_info_get_deletion_date(
166                self.to_glib_none().0,
167            ))
168        }
169    }
170
171    pub fn get_display_name(&self) -> Option<GString> {
172        unsafe { from_glib_none(gio_sys::g_file_info_get_display_name(self.to_glib_none().0)) }
173    }
174
175    pub fn get_edit_name(&self) -> Option<GString> {
176        unsafe { from_glib_none(gio_sys::g_file_info_get_edit_name(self.to_glib_none().0)) }
177    }
178
179    pub fn get_etag(&self) -> Option<GString> {
180        unsafe { from_glib_none(gio_sys::g_file_info_get_etag(self.to_glib_none().0)) }
181    }
182
183    pub fn get_file_type(&self) -> FileType {
184        unsafe { from_glib(gio_sys::g_file_info_get_file_type(self.to_glib_none().0)) }
185    }
186
187    pub fn get_icon(&self) -> Option<Icon> {
188        unsafe { from_glib_none(gio_sys::g_file_info_get_icon(self.to_glib_none().0)) }
189    }
190
191    pub fn get_is_backup(&self) -> bool {
192        unsafe { from_glib(gio_sys::g_file_info_get_is_backup(self.to_glib_none().0)) }
193    }
194
195    pub fn get_is_hidden(&self) -> bool {
196        unsafe { from_glib(gio_sys::g_file_info_get_is_hidden(self.to_glib_none().0)) }
197    }
198
199    pub fn get_is_symlink(&self) -> bool {
200        unsafe { from_glib(gio_sys::g_file_info_get_is_symlink(self.to_glib_none().0)) }
201    }
202
203    pub fn get_modification_time(&self) -> glib::TimeVal {
204        unsafe {
205            let mut result = glib::TimeVal::uninitialized();
206            gio_sys::g_file_info_get_modification_time(
207                self.to_glib_none().0,
208                result.to_glib_none_mut().0,
209            );
210            result
211        }
212    }
213
214    pub fn get_name(&self) -> Option<std::path::PathBuf> {
215        unsafe { from_glib_none(gio_sys::g_file_info_get_name(self.to_glib_none().0)) }
216    }
217
218    pub fn get_size(&self) -> i64 {
219        unsafe { gio_sys::g_file_info_get_size(self.to_glib_none().0) }
220    }
221
222    pub fn get_sort_order(&self) -> i32 {
223        unsafe { gio_sys::g_file_info_get_sort_order(self.to_glib_none().0) }
224    }
225
226    pub fn get_symbolic_icon(&self) -> Option<Icon> {
227        unsafe {
228            from_glib_none(gio_sys::g_file_info_get_symbolic_icon(
229                self.to_glib_none().0,
230            ))
231        }
232    }
233
234    pub fn get_symlink_target(&self) -> Option<GString> {
235        unsafe {
236            from_glib_none(gio_sys::g_file_info_get_symlink_target(
237                self.to_glib_none().0,
238            ))
239        }
240    }
241
242    pub fn has_attribute(&self, attribute: &str) -> bool {
243        unsafe {
244            from_glib(gio_sys::g_file_info_has_attribute(
245                self.to_glib_none().0,
246                attribute.to_glib_none().0,
247            ))
248        }
249    }
250
251    pub fn has_namespace(&self, name_space: &str) -> bool {
252        unsafe {
253            from_glib(gio_sys::g_file_info_has_namespace(
254                self.to_glib_none().0,
255                name_space.to_glib_none().0,
256            ))
257        }
258    }
259
260    pub fn list_attributes(&self, name_space: Option<&str>) -> Vec<GString> {
261        unsafe {
262            FromGlibPtrContainer::from_glib_full(gio_sys::g_file_info_list_attributes(
263                self.to_glib_none().0,
264                name_space.to_glib_none().0,
265            ))
266        }
267    }
268
269    pub fn remove_attribute(&self, attribute: &str) {
270        unsafe {
271            gio_sys::g_file_info_remove_attribute(
272                self.to_glib_none().0,
273                attribute.to_glib_none().0,
274            );
275        }
276    }
277
278    //pub fn set_attribute(&self, attribute: &str, type_: FileAttributeType, value_p: /*Unimplemented*/Fundamental: Pointer) {
279    //    unsafe { TODO: call gio_sys:g_file_info_set_attribute() }
280    //}
281
282    pub fn set_attribute_boolean(&self, attribute: &str, attr_value: bool) {
283        unsafe {
284            gio_sys::g_file_info_set_attribute_boolean(
285                self.to_glib_none().0,
286                attribute.to_glib_none().0,
287                attr_value.to_glib(),
288            );
289        }
290    }
291
292    pub fn set_attribute_byte_string(&self, attribute: &str, attr_value: &str) {
293        unsafe {
294            gio_sys::g_file_info_set_attribute_byte_string(
295                self.to_glib_none().0,
296                attribute.to_glib_none().0,
297                attr_value.to_glib_none().0,
298            );
299        }
300    }
301
302    pub fn set_attribute_int32(&self, attribute: &str, attr_value: i32) {
303        unsafe {
304            gio_sys::g_file_info_set_attribute_int32(
305                self.to_glib_none().0,
306                attribute.to_glib_none().0,
307                attr_value,
308            );
309        }
310    }
311
312    pub fn set_attribute_int64(&self, attribute: &str, attr_value: i64) {
313        unsafe {
314            gio_sys::g_file_info_set_attribute_int64(
315                self.to_glib_none().0,
316                attribute.to_glib_none().0,
317                attr_value,
318            );
319        }
320    }
321
322    pub fn set_attribute_mask(&self, mask: &FileAttributeMatcher) {
323        unsafe {
324            gio_sys::g_file_info_set_attribute_mask(self.to_glib_none().0, mask.to_glib_none().0);
325        }
326    }
327
328    pub fn set_attribute_object<P: IsA<glib::Object>>(&self, attribute: &str, attr_value: &P) {
329        unsafe {
330            gio_sys::g_file_info_set_attribute_object(
331                self.to_glib_none().0,
332                attribute.to_glib_none().0,
333                attr_value.as_ref().to_glib_none().0,
334            );
335        }
336    }
337
338    pub fn set_attribute_status(&self, attribute: &str, status: FileAttributeStatus) -> bool {
339        unsafe {
340            from_glib(gio_sys::g_file_info_set_attribute_status(
341                self.to_glib_none().0,
342                attribute.to_glib_none().0,
343                status.to_glib(),
344            ))
345        }
346    }
347
348    pub fn set_attribute_string(&self, attribute: &str, attr_value: &str) {
349        unsafe {
350            gio_sys::g_file_info_set_attribute_string(
351                self.to_glib_none().0,
352                attribute.to_glib_none().0,
353                attr_value.to_glib_none().0,
354            );
355        }
356    }
357
358    pub fn set_attribute_stringv(&self, attribute: &str, attr_value: &[&str]) {
359        unsafe {
360            gio_sys::g_file_info_set_attribute_stringv(
361                self.to_glib_none().0,
362                attribute.to_glib_none().0,
363                attr_value.to_glib_none().0,
364            );
365        }
366    }
367
368    pub fn set_attribute_uint32(&self, attribute: &str, attr_value: u32) {
369        unsafe {
370            gio_sys::g_file_info_set_attribute_uint32(
371                self.to_glib_none().0,
372                attribute.to_glib_none().0,
373                attr_value,
374            );
375        }
376    }
377
378    pub fn set_attribute_uint64(&self, attribute: &str, attr_value: u64) {
379        unsafe {
380            gio_sys::g_file_info_set_attribute_uint64(
381                self.to_glib_none().0,
382                attribute.to_glib_none().0,
383                attr_value,
384            );
385        }
386    }
387
388    pub fn set_content_type(&self, content_type: &str) {
389        unsafe {
390            gio_sys::g_file_info_set_content_type(
391                self.to_glib_none().0,
392                content_type.to_glib_none().0,
393            );
394        }
395    }
396
397    pub fn set_display_name(&self, display_name: &str) {
398        unsafe {
399            gio_sys::g_file_info_set_display_name(
400                self.to_glib_none().0,
401                display_name.to_glib_none().0,
402            );
403        }
404    }
405
406    pub fn set_edit_name(&self, edit_name: &str) {
407        unsafe {
408            gio_sys::g_file_info_set_edit_name(self.to_glib_none().0, edit_name.to_glib_none().0);
409        }
410    }
411
412    pub fn set_file_type(&self, type_: FileType) {
413        unsafe {
414            gio_sys::g_file_info_set_file_type(self.to_glib_none().0, type_.to_glib());
415        }
416    }
417
418    pub fn set_icon<P: IsA<Icon>>(&self, icon: &P) {
419        unsafe {
420            gio_sys::g_file_info_set_icon(self.to_glib_none().0, icon.as_ref().to_glib_none().0);
421        }
422    }
423
424    pub fn set_is_hidden(&self, is_hidden: bool) {
425        unsafe {
426            gio_sys::g_file_info_set_is_hidden(self.to_glib_none().0, is_hidden.to_glib());
427        }
428    }
429
430    pub fn set_is_symlink(&self, is_symlink: bool) {
431        unsafe {
432            gio_sys::g_file_info_set_is_symlink(self.to_glib_none().0, is_symlink.to_glib());
433        }
434    }
435
436    pub fn set_modification_time(&self, mtime: &mut glib::TimeVal) {
437        unsafe {
438            gio_sys::g_file_info_set_modification_time(
439                self.to_glib_none().0,
440                mtime.to_glib_none_mut().0,
441            );
442        }
443    }
444
445    pub fn set_name<P: AsRef<std::path::Path>>(&self, name: P) {
446        unsafe {
447            gio_sys::g_file_info_set_name(self.to_glib_none().0, name.as_ref().to_glib_none().0);
448        }
449    }
450
451    pub fn set_size(&self, size: i64) {
452        unsafe {
453            gio_sys::g_file_info_set_size(self.to_glib_none().0, size);
454        }
455    }
456
457    pub fn set_sort_order(&self, sort_order: i32) {
458        unsafe {
459            gio_sys::g_file_info_set_sort_order(self.to_glib_none().0, sort_order);
460        }
461    }
462
463    pub fn set_symbolic_icon<P: IsA<Icon>>(&self, icon: &P) {
464        unsafe {
465            gio_sys::g_file_info_set_symbolic_icon(
466                self.to_glib_none().0,
467                icon.as_ref().to_glib_none().0,
468            );
469        }
470    }
471
472    pub fn set_symlink_target(&self, symlink_target: &str) {
473        unsafe {
474            gio_sys::g_file_info_set_symlink_target(
475                self.to_glib_none().0,
476                symlink_target.to_glib_none().0,
477            );
478        }
479    }
480
481    pub fn unset_attribute_mask(&self) {
482        unsafe {
483            gio_sys::g_file_info_unset_attribute_mask(self.to_glib_none().0);
484        }
485    }
486}
487
488impl Default for FileInfo {
489    fn default() -> Self {
490        Self::new()
491    }
492}
493
494impl fmt::Display for FileInfo {
495    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
496        write!(f, "FileInfo")
497    }
498}