1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD 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
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gio.UnixMountEntry;
26 
27 private import gio.IconIF;
28 private import gio.c.functions;
29 public  import gio.c.types;
30 private import glib.ListG;
31 private import glib.Str;
32 private import gobject.ObjectG;
33 public  import gtkc.giotypes;
34 
35 
36 /**
37  * Defines a Unix mount entry (e.g. <filename>/media/cdrom</filename>).
38  * This corresponds roughly to a mtab entry.
39  */
40 public class UnixMountEntry
41 {
42 	/** the main Gtk struct */
43 	protected GUnixMountEntry* gUnixMountEntry;
44 	protected bool ownedRef;
45 
46 	/** Get the main Gtk struct */
47 	public GUnixMountEntry* getUnixMountEntryStruct(bool transferOwnership = false)
48 	{
49 		if (transferOwnership)
50 			ownedRef = false;
51 		return gUnixMountEntry;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected void* getStruct()
56 	{
57 		return cast(void*)gUnixMountEntry;
58 	}
59 
60 	/**
61 	 * Sets our main struct and passes it to the parent class.
62 	 */
63 	public this (GUnixMountEntry* gUnixMountEntry, bool ownedRef = false)
64 	{
65 		this.gUnixMountEntry = gUnixMountEntry;
66 		this.ownedRef = ownedRef;
67 	}
68 
69 
70 	/** */
71 	public static GType getType()
72 	{
73 		return g_unix_mount_entry_get_type();
74 	}
75 
76 	/**
77 	 * Determines if @mount_path is considered an implementation of the
78 	 * OS. This is primarily used for hiding mountable and mounted volumes
79 	 * that only are used in the OS and has little to no relevance to the
80 	 * casual user.
81 	 *
82 	 * Params:
83 	 *     mountPath = a mount path, e.g. `/media/disk` or `/usr`
84 	 *
85 	 * Returns: %TRUE if @mount_path is considered an implementation detail
86 	 *     of the OS.
87 	 */
88 	public static bool isMountPathSystemInternal(string mountPath)
89 	{
90 		return g_unix_is_mount_path_system_internal(Str.toStringz(mountPath)) != 0;
91 	}
92 
93 	/**
94 	 * Gets a #GUnixMountEntry for a given mount path. If @time_read
95 	 * is set, it will be filled with a unix timestamp for checking
96 	 * if the mounts have changed since with g_unix_mounts_changed_since().
97 	 *
98 	 * If more mounts have the same mount path, the last matching mount
99 	 * is returned.
100 	 *
101 	 * Params:
102 	 *     mountPath = path for a possible unix mount.
103 	 *     timeRead = guint64 to contain a timestamp.
104 	 *
105 	 * Returns: a #GUnixMountEntry.
106 	 */
107 	public static UnixMountEntry at(string mountPath, out ulong timeRead)
108 	{
109 		auto __p = g_unix_mount_at(Str.toStringz(mountPath), &timeRead);
110 
111 		if(__p is null)
112 		{
113 			return null;
114 		}
115 
116 		return ObjectG.getDObject!(UnixMountEntry)(cast(GUnixMountEntry*) __p, true);
117 	}
118 
119 	/**
120 	 * Compares two unix mounts.
121 	 *
122 	 * Params:
123 	 *     mount2 = second #GUnixMountEntry to compare.
124 	 *
125 	 * Returns: 1, 0 or -1 if @mount1 is greater than, equal to,
126 	 *     or less than @mount2, respectively.
127 	 */
128 	public int compare(UnixMountEntry mount2)
129 	{
130 		return g_unix_mount_compare(gUnixMountEntry, (mount2 is null) ? null : mount2.getUnixMountEntryStruct());
131 	}
132 
133 	/**
134 	 * Frees a unix mount.
135 	 */
136 	public void free()
137 	{
138 		g_unix_mount_free(gUnixMountEntry);
139 	}
140 
141 	/**
142 	 * Gets the device path for a unix mount.
143 	 *
144 	 * Returns: a string containing the device path.
145 	 */
146 	public string getDevicePath()
147 	{
148 		return Str.toString(g_unix_mount_get_device_path(gUnixMountEntry));
149 	}
150 
151 	/**
152 	 * Gets the filesystem type for the unix mount.
153 	 *
154 	 * Returns: a string containing the file system type.
155 	 */
156 	public string getFsType()
157 	{
158 		return Str.toString(g_unix_mount_get_fs_type(gUnixMountEntry));
159 	}
160 
161 	/**
162 	 * Gets the mount path for a unix mount.
163 	 *
164 	 * Returns: the mount path for @mount_entry.
165 	 */
166 	public string getMountPath()
167 	{
168 		return Str.toString(g_unix_mount_get_mount_path(gUnixMountEntry));
169 	}
170 
171 	/**
172 	 * Guesses whether a Unix mount can be ejected.
173 	 *
174 	 * Returns: %TRUE if @mount_entry is deemed to be ejectable.
175 	 */
176 	public bool guessCanEject()
177 	{
178 		return g_unix_mount_guess_can_eject(gUnixMountEntry) != 0;
179 	}
180 
181 	/**
182 	 * Guesses the icon of a Unix mount.
183 	 *
184 	 * Returns: a #GIcon
185 	 */
186 	public IconIF guessIcon()
187 	{
188 		auto __p = g_unix_mount_guess_icon(gUnixMountEntry);
189 
190 		if(__p is null)
191 		{
192 			return null;
193 		}
194 
195 		return ObjectG.getDObject!(IconIF)(cast(GIcon*) __p, true);
196 	}
197 
198 	/**
199 	 * Guesses the name of a Unix mount.
200 	 * The result is a translated string.
201 	 *
202 	 * Returns: A newly allocated string that must
203 	 *     be freed with g_free()
204 	 */
205 	public string guessName()
206 	{
207 		auto retStr = g_unix_mount_guess_name(gUnixMountEntry);
208 
209 		scope(exit) Str.freeString(retStr);
210 		return Str.toString(retStr);
211 	}
212 
213 	/**
214 	 * Guesses whether a Unix mount should be displayed in the UI.
215 	 *
216 	 * Returns: %TRUE if @mount_entry is deemed to be displayable.
217 	 */
218 	public bool guessShouldDisplay()
219 	{
220 		return g_unix_mount_guess_should_display(gUnixMountEntry) != 0;
221 	}
222 
223 	/**
224 	 * Guesses the symbolic icon of a Unix mount.
225 	 *
226 	 * Returns: a #GIcon
227 	 *
228 	 * Since: 2.34
229 	 */
230 	public IconIF guessSymbolicIcon()
231 	{
232 		auto __p = g_unix_mount_guess_symbolic_icon(gUnixMountEntry);
233 
234 		if(__p is null)
235 		{
236 			return null;
237 		}
238 
239 		return ObjectG.getDObject!(IconIF)(cast(GIcon*) __p, true);
240 	}
241 
242 	/**
243 	 * Checks if a unix mount is mounted read only.
244 	 *
245 	 * Returns: %TRUE if @mount_entry is read only.
246 	 */
247 	public bool isReadonly()
248 	{
249 		return g_unix_mount_is_readonly(gUnixMountEntry) != 0;
250 	}
251 
252 	/**
253 	 * Checks if a Unix mount is a system mount. This is the Boolean OR of
254 	 * g_unix_is_system_fs_type(), g_unix_is_system_device_path() and
255 	 * g_unix_is_mount_path_system_internal() on @mount_entry’s properties.
256 	 *
257 	 * The definition of what a ‘system’ mount entry is may change over time as new
258 	 * file system types and device paths are ignored.
259 	 *
260 	 * Returns: %TRUE if the unix mount is for a system path.
261 	 */
262 	public bool isSystemInternal()
263 	{
264 		return g_unix_mount_is_system_internal(gUnixMountEntry) != 0;
265 	}
266 
267 	/**
268 	 * Checks if the unix mount points have changed since a given unix time.
269 	 *
270 	 * Params:
271 	 *     time = guint64 to contain a timestamp.
272 	 *
273 	 * Returns: %TRUE if the mount points have changed since @time.
274 	 */
275 	public static bool pointsChangedSince(ulong time)
276 	{
277 		return g_unix_mount_points_changed_since(time) != 0;
278 	}
279 
280 	/**
281 	 * Gets a #GList of #GUnixMountPoint containing the unix mount points.
282 	 * If @time_read is set, it will be filled with the mount timestamp,
283 	 * allowing for checking if the mounts have changed with
284 	 * g_unix_mount_points_changed_since().
285 	 *
286 	 * Params:
287 	 *     timeRead = guint64 to contain a timestamp.
288 	 *
289 	 * Returns: a #GList of the UNIX mountpoints.
290 	 */
291 	public static ListG mountPointsGet(out ulong timeRead)
292 	{
293 		auto __p = g_unix_mount_points_get(&timeRead);
294 
295 		if(__p is null)
296 		{
297 			return null;
298 		}
299 
300 		return new ListG(cast(GList*) __p, true);
301 	}
302 
303 	/**
304 	 * Checks if the unix mounts have changed since a given unix time.
305 	 *
306 	 * Params:
307 	 *     time = guint64 to contain a timestamp.
308 	 *
309 	 * Returns: %TRUE if the mounts have changed since @time.
310 	 */
311 	public static bool mountsChangedSince(ulong time)
312 	{
313 		return g_unix_mounts_changed_since(time) != 0;
314 	}
315 
316 	/**
317 	 * Gets a #GList of #GUnixMountEntry containing the unix mounts.
318 	 * If @time_read is set, it will be filled with the mount
319 	 * timestamp, allowing for checking if the mounts have changed
320 	 * with g_unix_mounts_changed_since().
321 	 *
322 	 * Params:
323 	 *     timeRead = guint64 to contain a timestamp, or %NULL
324 	 *
325 	 * Returns: a #GList of the UNIX mounts.
326 	 */
327 	public static ListG mountsGet(out ulong timeRead)
328 	{
329 		auto __p = g_unix_mounts_get(&timeRead);
330 
331 		if(__p is null)
332 		{
333 			return null;
334 		}
335 
336 		return new ListG(cast(GList*) __p, true);
337 	}
338 
339 	/**
340 	 * Makes a copy of @mount_entry.
341 	 *
342 	 * Returns: a new #GUnixMountEntry
343 	 *
344 	 * Since: 2.54
345 	 */
346 	public UnixMountEntry copy()
347 	{
348 		auto __p = g_unix_mount_copy(gUnixMountEntry);
349 
350 		if(__p is null)
351 		{
352 			return null;
353 		}
354 
355 		return ObjectG.getDObject!(UnixMountEntry)(cast(GUnixMountEntry*) __p, true);
356 	}
357 
358 	/**
359 	 * Gets a #GUnixMountEntry for a given file path. If @time_read
360 	 * is set, it will be filled with a unix timestamp for checking
361 	 * if the mounts have changed since with g_unix_mounts_changed_since().
362 	 *
363 	 * If more mounts have the same mount path, the last matching mount
364 	 * is returned.
365 	 *
366 	 * Params:
367 	 *     filePath = file path on some unix mount.
368 	 *     timeRead = guint64 to contain a timestamp.
369 	 *
370 	 * Returns: a #GUnixMountEntry.
371 	 *
372 	 * Since: 2.52
373 	 */
374 	public static UnixMountEntry mountFor(string filePath, out ulong timeRead)
375 	{
376 		auto __p = g_unix_mount_for(Str.toStringz(filePath), &timeRead);
377 
378 		if(__p is null)
379 		{
380 			return null;
381 		}
382 
383 		return ObjectG.getDObject!(UnixMountEntry)(cast(GUnixMountEntry*) __p, true);
384 	}
385 
386 	/**
387 	 * Gets a comma-separated list of mount options for the unix mount. For example,
388 	 * `rw,relatime,seclabel,data=ordered`.
389 	 *
390 	 * This is similar to g_unix_mount_point_get_options(), but it takes
391 	 * a #GUnixMountEntry as an argument.
392 	 *
393 	 * Returns: a string containing the options, or %NULL if not
394 	 *     available.
395 	 *
396 	 * Since: 2.58
397 	 */
398 	public string getOptions()
399 	{
400 		return Str.toString(g_unix_mount_get_options(gUnixMountEntry));
401 	}
402 
403 	/**
404 	 * Gets the root of the mount within the filesystem. This is useful e.g. for
405 	 * mounts created by bind operation, or btrfs subvolumes.
406 	 *
407 	 * For example, the root path is equal to "/" for mount created by
408 	 * "mount /dev/sda1 /mnt/foo" and "/bar" for
409 	 * "mount --bind /mnt/foo/bar /mnt/bar".
410 	 *
411 	 * Returns: a string containing the root, or %NULL if not supported.
412 	 *
413 	 * Since: 2.60
414 	 */
415 	public string getRootPath()
416 	{
417 		return Str.toString(g_unix_mount_get_root_path(gUnixMountEntry));
418 	}
419 }