summaryrefslogtreecommitdiff
path: root/client/gfiledaemonlocal.c
blob: 7806b3fb402014e9ef8a5924ab0d5706c3a44d77 (plain)
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
#include <config.h>

#include <string.h>

#include <gio/gfileinputstreamlocal.h>
#include <gio/gfileoutputstreamlocal.h>
#include "gfiledaemonlocal.h"
#include <glib/gi18n-lib.h>

static void g_file_daemon_local_file_iface_init (GFileIface       *iface);

struct _GFileDaemonLocal
{
  GObject parent_instance;

  GFile *wrapped;
};

G_DEFINE_TYPE_WITH_CODE (GFileDaemonLocal, g_file_daemon_local, G_TYPE_OBJECT,
			 G_IMPLEMENT_INTERFACE (G_TYPE_FILE,
						g_file_daemon_local_file_iface_init))

static void
g_file_daemon_local_finalize (GObject *object)
{
  GFileDaemonLocal *daemon_local;

  daemon_local = G_FILE_DAEMON_LOCAL (object);

  g_object_unref (daemon_local->wrapped);
  
  if (G_OBJECT_CLASS (g_file_daemon_local_parent_class)->finalize)
    (*G_OBJECT_CLASS (g_file_daemon_local_parent_class)->finalize) (object);
}

static void
g_file_daemon_local_class_init (GFileDaemonLocalClass *klass)
{
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
  
  gobject_class->finalize = g_file_daemon_local_finalize;
}

static void
g_file_daemon_local_init (GFileDaemonLocal *daemon_local)
{
}

GFile *
g_file_daemon_local_new (GFile *wrapped)
{
  GFileDaemonLocal *daemon_local = g_object_new (G_TYPE_FILE_DAEMON_LOCAL, NULL);
  daemon_local->wrapped = wrapped;
  return G_FILE (daemon_local);
}

static gboolean
g_file_daemon_local_is_native (GFile *file)
{
  return TRUE;
}

static char *
g_file_daemon_local_get_path (GFile *file)
{
  return g_file_get_path (G_FILE_DAEMON_LOCAL (file)->wrapped);
}

static char *
g_file_daemon_local_get_uri (GFile *file)
{
  return g_file_get_uri (G_FILE_DAEMON_LOCAL (file)->wrapped);
}

static char *
g_file_daemon_local_get_parse_name (GFile *file)
{
  return g_file_get_parse_name (G_FILE_DAEMON_LOCAL (file)->wrapped);
}

static GFile *
g_file_daemon_local_get_parent (GFile *file)
{
  GFile *parent;

  parent = g_file_get_parent (G_FILE_DAEMON_LOCAL (file)->wrapped);
  if (parent == NULL)
    return NULL;
  return g_file_daemon_local_new (parent);
}

static GFile *
g_file_daemon_local_copy (GFile *file)
{
  GFile *copy;

  copy = g_file_copy (G_FILE_DAEMON_LOCAL (file)->wrapped);
  return g_file_daemon_local_new (copy);
}


static GFile *
g_file_daemon_local_get_child (GFile *file,
			       const char *name)
{
  GFile *child;

  child = g_file_get_child (G_FILE_DAEMON_LOCAL (file)->wrapped, name);
  if (child == NULL)
    return NULL;
  
  return g_file_daemon_local_new (child);
}

static GFileEnumerator *
g_file_daemon_local_enumerate_children (GFile *file,
					GFileInfoRequestFlags requested,
					const char *attributes,
					gboolean follow_symlinks,
					GCancellable *cancellable,
					GError **error)
{
  return g_file_enumerate_children (G_FILE_DAEMON_LOCAL (file)->wrapped,
				    requested, attributes, follow_symlinks,
				    cancellable, error);
}

static GFileInfo *
g_file_daemon_local_get_info (GFile *file,
			      GFileInfoRequestFlags requested,
			      const char *attributes,
			      gboolean follow_symlinks,
			      GCancellable *cancellable,
			      GError **error)
{
  return g_file_get_info (G_FILE_DAEMON_LOCAL (file)->wrapped,
			  requested, attributes, follow_symlinks,
			  cancellable, error);
}

static GFileInputStream *
g_file_daemon_local_read (GFile *file,
			  GCancellable *cancellable,
			  GError **error)
{
  return g_file_read (G_FILE_DAEMON_LOCAL (file)->wrapped,
		      cancellable, error);
}

static GFileOutputStream *
g_file_daemon_local_append_to (GFile *file,
			       GCancellable *cancellable,
			       GError **error)
{
  return g_file_append_to (G_FILE_DAEMON_LOCAL (file)->wrapped, cancellable, error);
}

static GFileOutputStream *
g_file_daemon_local_create (GFile *file,
			    GCancellable *cancellable,
			    GError **error)
{
  return g_file_create (G_FILE_DAEMON_LOCAL (file)->wrapped, cancellable, error);
}

static GFileOutputStream *
g_file_daemon_local_replace (GFile *file,
			     time_t mtime,
			     gboolean  make_backup,
			     GCancellable *cancellable,
			     GError **error)
{
  return g_file_replace (G_FILE_DAEMON_LOCAL (file)->wrapped, mtime, make_backup, cancellable, error);
}

static void
g_file_daemon_local_file_iface_init (GFileIface *iface)
{
  iface->copy = g_file_daemon_local_copy;
  iface->is_native = g_file_daemon_local_is_native;
  iface->get_path = g_file_daemon_local_get_path;
  iface->get_uri = g_file_daemon_local_get_uri;
  iface->get_parse_name = g_file_daemon_local_get_parse_name;
  iface->get_parent = g_file_daemon_local_get_parent;
  iface->get_child = g_file_daemon_local_get_child;
  iface->enumerate_children = g_file_daemon_local_enumerate_children;
  iface->get_info = g_file_daemon_local_get_info;
  iface->read = g_file_daemon_local_read;
  iface->append_to = g_file_daemon_local_append_to;
  iface->create = g_file_daemon_local_create;
  iface->replace = g_file_daemon_local_replace;
}