1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2006-2007 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Alexander Larsson <alexl@redhat.com>
26 #include <glib-object.h>
27 #include <gio/gfileinfo.h>
28 #include <gio/gfileenumerator.h>
29 #include <gio/gfileinputstream.h>
30 #include <gio/gfileoutputstream.h>
31 #include <gio/gmountoperation.h>
35 #define G_TYPE_FILE (g_file_get_type ())
36 #define G_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_FILE, GFile))
37 #define G_IS_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_FILE))
38 #define G_FILE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_FILE, GFileIface))
41 G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS = (1<<0)
42 } GFileQueryInfoFlags;
45 G_FILE_CREATE_FLAGS_NONE = 0,
46 G_FILE_CREATE_FLAGS_PRIVATE = (1<<0)
50 G_FILE_COPY_OVERWRITE = (1<<0),
51 G_FILE_COPY_BACKUP = (1<<1),
52 G_FILE_COPY_NOFOLLOW_SYMLINKS = (1<<2),
53 G_FILE_COPY_ALL_METADATA = (1<<3)
57 G_FILE_MONITOR_FLAGS_NONE = 0,
58 G_FILE_MONITOR_FLAGS_MONITOR_MOUNTS = (1<<0)
61 typedef struct _GFile GFile; /* Dummy typedef */
62 typedef struct _GFileIface GFileIface;
63 typedef struct _GDirectoryMonitor GDirectoryMonitor;
64 typedef struct _GFileMonitor GFileMonitor;
65 typedef struct _GVolume GVolume; /* Dummy typedef */
67 typedef void (*GFileProgressCallback) (goffset current_num_bytes,
68 goffset total_num_bytes,
70 typedef gboolean (* GFileReadMoreCallback) (const char *file_contents,
72 gpointer callback_data);
77 GTypeInterface g_iface;
81 GFile * (*dup) (GFile *file);
82 guint (*hash) (GFile *file);
83 gboolean (*equal) (GFile *file1,
85 gboolean (*is_native) (GFile *file);
86 gboolean (*has_uri_scheme) (GFile *file,
87 const char *uri_scheme);
88 char * (*get_uri_scheme) (GFile *file);
89 char * (*get_basename) (GFile *file);
90 char * (*get_path) (GFile *file);
91 char * (*get_uri) (GFile *file);
92 char * (*get_parse_name) (GFile *file);
93 GFile * (*get_parent) (GFile *file);
94 gboolean (*contains_file) (GFile *parent,
96 char * (*get_relative_path) (GFile *parent,
98 GFile * (*resolve_relative_path) (GFile *file,
99 const char *relative_path);
100 GFile * (*get_child_for_display_name) (GFile *file,
101 const char *display_name,
104 GFileEnumerator * (*enumerate_children) (GFile *file,
105 const char *attributes,
106 GFileQueryInfoFlags flags,
107 GCancellable *cancellable,
109 void (*enumerate_children_async) (GFile *file,
110 const char *attributes,
111 GFileQueryInfoFlags flags,
113 GCancellable *cancellable,
114 GAsyncReadyCallback callback,
116 GFileEnumerator * (*enumerate_children_finish) (GFile *file,
120 GFileInfo * (*query_info) (GFile *file,
121 const char *attributes,
122 GFileQueryInfoFlags flags,
123 GCancellable *cancellable,
125 void (*query_info_async) (GFile *file,
126 const char *attributes,
127 GFileQueryInfoFlags flags,
129 GCancellable *cancellable,
130 GAsyncReadyCallback callback,
132 GFileInfo * (*query_info_finish) (GFile *file,
136 GFileInfo * (*query_filesystem_info)(GFile *file,
137 const char *attributes,
138 GCancellable *cancellable,
140 void (*_query_filesystem_info_async) (void);
141 void (*_query_filesystem_info_finish) (void);
143 GVolume * (*find_enclosing_volume)(GFile *file,
144 GCancellable *cancellable,
146 void (*find_enclosing_volume_async)(GFile *file,
148 GCancellable *cancellable,
149 GAsyncReadyCallback callback,
151 GVolume * (*find_enclosing_volume_finish)(GFile *file,
155 GFile * (*set_display_name) (GFile *file,
156 const char *display_name,
157 GCancellable *cancellable,
159 void (*set_display_name_async) (GFile *file,
160 const char *display_name,
162 GCancellable *cancellable,
163 GAsyncReadyCallback callback,
165 GFile * (*set_display_name_finish) (GFile *file,
169 GFileAttributeInfoList * (*query_settable_attributes) (GFile *file,
170 GCancellable *cancellable,
172 void (*_query_settable_attributes_async) (void);
173 void (*_query_settable_attributes_finish) (void);
175 GFileAttributeInfoList * (*query_writable_namespaces) (GFile *file,
176 GCancellable *cancellable,
178 void (*_query_writable_namespaces_async) (void);
179 void (*_query_writable_namespaces_finish) (void);
181 gboolean (*set_attribute) (GFile *file,
182 const char *attribute,
183 const GFileAttributeValue *value,
184 GFileQueryInfoFlags flags,
185 GCancellable *cancellable,
187 gboolean (*set_attributes_from_info) (GFile *file,
189 GFileQueryInfoFlags flags,
190 GCancellable *cancellable,
192 void (*set_attributes_async) (GFile *file,
194 GFileQueryInfoFlags flags,
196 GCancellable *cancellable,
197 GAsyncReadyCallback callback,
199 gboolean (*set_attributes_finish) (GFile *file,
200 GAsyncResult *result,
204 GFileInputStream * (*read) (GFile *file,
205 GCancellable *cancellable,
207 void (*read_async) (GFile *file,
209 GCancellable *cancellable,
210 GAsyncReadyCallback callback,
212 GFileInputStream * (*read_finish) (GFile *file,
216 GFileOutputStream * (*append_to) (GFile *file,
217 GFileCreateFlags flags,
218 GCancellable *cancellable,
220 void (*append_to_async) (GFile *file,
221 GFileCreateFlags flags,
223 GCancellable *cancellable,
224 GAsyncReadyCallback callback,
226 GFileOutputStream * (*append_to_finish) (GFile *file,
230 GFileOutputStream * (*create) (GFile *file,
231 GFileCreateFlags flags,
232 GCancellable *cancellable,
234 void (*create_async) (GFile *file,
235 GFileCreateFlags flags,
237 GCancellable *cancellable,
238 GAsyncReadyCallback callback,
240 GFileOutputStream * (*create_finish) (GFile *file,
244 GFileOutputStream * (*replace) (GFile *file,
246 gboolean make_backup,
247 GFileCreateFlags flags,
248 GCancellable *cancellable,
250 void (*replace_async) (GFile *file,
252 gboolean make_backup,
253 GFileCreateFlags flags,
255 GCancellable *cancellable,
256 GAsyncReadyCallback callback,
258 GFileOutputStream * (*replace_finish) (GFile *file,
262 gboolean (*delete_file) (GFile *file,
263 GCancellable *cancellable,
265 void (*_delete_file_async) (void);
266 void (*_delete_file_finish) (void);
268 gboolean (*trash) (GFile *file,
269 GCancellable *cancellable,
271 void (*_trash_async) (void);
272 void (*_trash_finish) (void);
274 gboolean (*make_directory) (GFile *file,
275 GCancellable *cancellable,
277 void (*_make_directory_async) (void);
278 void (*_make_directory_finish) (void);
280 gboolean (*make_symbolic_link) (GFile *file,
281 const char *symlink_value,
282 GCancellable *cancellable,
284 void (*_make_symbolic_link_async) (void);
285 void (*_make_symbolic_link_finish) (void);
287 gboolean (*copy) (GFile *source,
289 GFileCopyFlags flags,
290 GCancellable *cancellable,
291 GFileProgressCallback progress_callback,
292 gpointer progress_callback_data,
294 void (*_copy_async) (void);
295 void (*_copy_finish) (void);
297 gboolean (*move) (GFile *source,
299 GFileCopyFlags flags,
300 GCancellable *cancellable,
301 GFileProgressCallback progress_callback,
302 gpointer progress_callback_data,
305 void (*_move_async) (void);
306 void (*_move_finish) (void);
309 void (*mount_mountable) (GFile *file,
310 GMountOperation *mount_operation,
311 GCancellable *cancellable,
312 GAsyncReadyCallback callback,
314 GFile * (*mount_mountable_finish) (GFile *file,
315 GAsyncResult *result,
317 void (*unmount_mountable) (GFile *file,
318 GCancellable *cancellable,
319 GAsyncReadyCallback callback,
321 gboolean (*unmount_mountable_finish) (GFile *file,
322 GAsyncResult *result,
324 void (*eject_mountable) (GFile *file,
325 GCancellable *cancellable,
326 GAsyncReadyCallback callback,
328 gboolean (*eject_mountable_finish) (GFile *file,
329 GAsyncResult *result,
333 void (*mount_for_location) (GFile *location,
334 GMountOperation *mount_operation,
335 GCancellable *cancellable,
336 GAsyncReadyCallback callback,
338 gboolean (*mount_for_location_finish) (GFile *location,
339 GAsyncResult *result,
342 GDirectoryMonitor* (*monitor_dir) (GFile *file,
343 GFileMonitorFlags flags,
344 GCancellable *cancellable);
346 GFileMonitor* (*monitor_file) (GFile *file,
347 GFileMonitorFlags flags,
348 GCancellable *cancellable);
351 GType g_file_get_type (void) G_GNUC_CONST;
353 GFile * g_file_new_for_path (const char *path);
354 GFile * g_file_new_for_uri (const char *uri);
355 GFile * g_file_new_for_commandline_arg (const char *arg);
356 GFile * g_file_parse_name (const char *parse_name);
357 GFile * g_file_dup (GFile *file);
358 guint g_file_hash (gconstpointer file);
359 gboolean g_file_equal (GFile *file1,
361 char * g_file_get_basename (GFile *file);
362 char * g_file_get_path (GFile *file);
363 char * g_file_get_uri (GFile *file);
364 char * g_file_get_parse_name (GFile *file);
365 GFile * g_file_get_parent (GFile *file);
366 GFile * g_file_get_child (GFile *file,
368 GFile * g_file_get_child_for_display_name (GFile *file,
369 const char *display_name,
371 gboolean g_file_contains_file (GFile *parent,
373 char * g_file_get_relative_path (GFile *parent,
375 GFile * g_file_resolve_relative_path (GFile *file,
376 const char *relative_path);
377 gboolean g_file_is_native (GFile *file);
378 gboolean g_file_has_uri_scheme (GFile *file,
379 const char *uri_scheme);
380 char * g_file_get_uri_scheme (GFile *file);
381 GFileInputStream * g_file_read (GFile *file,
382 GCancellable *cancellable,
384 void g_file_read_async (GFile *file,
386 GCancellable *cancellable,
387 GAsyncReadyCallback callback,
389 GFileInputStream * g_file_read_finish (GFile *file,
392 GFileOutputStream * g_file_append_to (GFile *file,
393 GFileCreateFlags flags,
394 GCancellable *cancellable,
396 GFileOutputStream * g_file_create (GFile *file,
397 GFileCreateFlags flags,
398 GCancellable *cancellable,
400 GFileOutputStream * g_file_replace (GFile *file,
402 gboolean make_backup,
403 GFileCreateFlags flags,
404 GCancellable *cancellable,
406 void g_file_append_to_async (GFile *file,
407 GFileCreateFlags flags,
409 GCancellable *cancellable,
410 GAsyncReadyCallback callback,
412 GFileOutputStream * g_file_append_to_finish (GFile *file,
415 void g_file_create_async (GFile *file,
416 GFileCreateFlags flags,
418 GCancellable *cancellable,
419 GAsyncReadyCallback callback,
421 GFileOutputStream * g_file_create_finish (GFile *file,
424 void g_file_replace_async (GFile *file,
426 gboolean make_backup,
427 GFileCreateFlags flags,
429 GCancellable *cancellable,
430 GAsyncReadyCallback callback,
432 GFileOutputStream * g_file_replace_finish (GFile *file,
435 GFileInfo * g_file_query_info (GFile *file,
436 const char *attributes,
437 GFileQueryInfoFlags flags,
438 GCancellable *cancellable,
440 void g_file_query_info_async (GFile *file,
441 const char *attributes,
442 GFileQueryInfoFlags flags,
444 GCancellable *cancellable,
445 GAsyncReadyCallback callback,
447 GFileInfo * g_file_query_info_finish (GFile *file,
450 GFileInfo * g_file_query_filesystem_info (GFile *file,
451 const char *attributes,
452 GCancellable *cancellable,
454 GVolume * g_file_find_enclosing_volume (GFile *file,
455 GCancellable *cancellable,
457 GFileEnumerator * g_file_enumerate_children (GFile *file,
458 const char *attributes,
459 GFileQueryInfoFlags flags,
460 GCancellable *cancellable,
462 void g_file_enumerate_children_async (GFile *file,
463 const char *attributes,
464 GFileQueryInfoFlags flags,
466 GCancellable *cancellable,
467 GAsyncReadyCallback callback,
469 GFileEnumerator * g_file_enumerate_children_finish (GFile *file,
472 GFile * g_file_set_display_name (GFile *file,
473 const char *display_name,
474 GCancellable *cancellable,
476 void g_file_set_display_name_async (GFile *file,
477 const char *display_name,
479 GCancellable *cancellable,
480 GAsyncReadyCallback callback,
482 GFile * g_file_set_display_name_finish (GFile *file,
485 gboolean g_file_delete (GFile *file,
486 GCancellable *cancellable,
488 gboolean g_file_trash (GFile *file,
489 GCancellable *cancellable,
491 gboolean g_file_copy (GFile *source,
493 GFileCopyFlags flags,
494 GCancellable *cancellable,
495 GFileProgressCallback progress_callback,
496 gpointer progress_callback_data,
498 gboolean g_file_move (GFile *source,
500 GFileCopyFlags flags,
501 GCancellable *cancellable,
502 GFileProgressCallback progress_callback,
503 gpointer progress_callback_data,
505 gboolean g_file_make_directory (GFile *file,
506 GCancellable *cancellable,
508 gboolean g_file_make_symbolic_link (GFile *file,
509 const char *symlink_value,
510 GCancellable *cancellable,
512 GFileAttributeInfoList *g_file_query_settable_attributes (GFile *file,
513 GCancellable *cancellable,
515 GFileAttributeInfoList *g_file_query_writable_namespaces (GFile *file,
516 GCancellable *cancellable,
518 gboolean g_file_set_attribute (GFile *file,
519 const char *attribute,
520 const GFileAttributeValue *value,
521 GFileQueryInfoFlags flags,
522 GCancellable *cancellable,
524 gboolean g_file_set_attributes_from_info (GFile *file,
526 GFileQueryInfoFlags flags,
527 GCancellable *cancellable,
529 void g_file_set_attributes_async (GFile *file,
531 GFileQueryInfoFlags flags,
533 GCancellable *cancellable,
534 GAsyncReadyCallback callback,
536 gboolean g_file_set_attributes_finish (GFile *file,
537 GAsyncResult *result,
540 gboolean g_file_set_attribute_string (GFile *file,
541 const char *attribute,
543 GFileQueryInfoFlags flags,
544 GCancellable *cancellable,
546 gboolean g_file_set_attribute_byte_string (GFile *file,
547 const char *attribute,
549 GFileQueryInfoFlags flags,
550 GCancellable *cancellable,
552 gboolean g_file_set_attribute_uint32 (GFile *file,
553 const char *attribute,
555 GFileQueryInfoFlags flags,
556 GCancellable *cancellable,
558 gboolean g_file_set_attribute_int32 (GFile *file,
559 const char *attribute,
561 GFileQueryInfoFlags flags,
562 GCancellable *cancellable,
564 gboolean g_file_set_attribute_uint64 (GFile *file,
565 const char *attribute,
567 GFileQueryInfoFlags flags,
568 GCancellable *cancellable,
570 gboolean g_file_set_attribute_int64 (GFile *file,
571 const char *attribute,
573 GFileQueryInfoFlags flags,
574 GCancellable *cancellable,
576 void g_mount_for_location (GFile *location,
577 GMountOperation *mount_operation,
578 GCancellable *cancellable,
579 GAsyncReadyCallback callback,
581 gboolean g_mount_for_location_finish (GFile *location,
582 GAsyncResult *result,
584 void g_file_mount_mountable (GFile *file,
585 GMountOperation *mount_operation,
586 GCancellable *cancellable,
587 GAsyncReadyCallback callback,
589 GFile * g_file_mount_mountable_finish (GFile *file,
590 GAsyncResult *result,
592 void g_file_unmount_mountable (GFile *file,
593 GCancellable *cancellable,
594 GAsyncReadyCallback callback,
596 gboolean g_file_unmount_mountable_finish (GFile *file,
597 GAsyncResult *result,
599 void g_file_eject_mountable (GFile *file,
600 GCancellable *cancellable,
601 GAsyncReadyCallback callback,
603 gboolean g_file_eject_mountable_finish (GFile *file,
604 GAsyncResult *result,
607 gboolean g_file_copy_attributes (GFile *source,
609 GFileCopyFlags flags,
610 GCancellable *cancellable,
614 GDirectoryMonitor* g_file_monitor_directory (GFile *file,
615 GFileMonitorFlags flags,
616 GCancellable *cancellable);
617 GFileMonitor* g_file_monitor_file (GFile *file,
618 GFileMonitorFlags flags,
619 GCancellable *cancellable);
624 gboolean g_file_load_contents (GFile *file,
625 GCancellable *cancellable,
630 void g_file_load_contents_async (GFile *file,
631 GCancellable *cancellable,
632 GAsyncReadyCallback callback,
634 gboolean g_file_load_contents_finish (GFile *file,
640 void g_file_load_partial_contents_async (GFile *file,
641 GCancellable *cancellable,
642 GFileReadMoreCallback read_more_callback,
643 GAsyncReadyCallback callback,
645 gboolean g_file_load_partial_contents_finish (GFile *file,
651 gboolean g_file_replace_contents (GFile *file,
652 const char *contents,
655 gboolean make_backup,
656 GFileCreateFlags flags,
658 GCancellable *cancellable,
660 void g_file_replace_contents_async (GFile *file,
661 const char *contents,
664 gboolean make_backup,
665 GFileCreateFlags flags,
666 GCancellable *cancellable,
667 GAsyncReadyCallback callback,
669 gboolean g_file_replace_contents_finish (GFile *file,
676 #endif /* __G_FILE_H__ */