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.Vfs;
26 
27 private import gio.File;
28 private import gio.FileIF;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 private import gtkc.gio;
32 public  import gtkc.giotypes;
33 
34 
35 /**
36  * Entry point for using GIO functionality.
37  */
38 public class Vfs : ObjectG
39 {
40 	/** the main Gtk struct */
41 	protected GVfs* gVfs;
42 
43 	/** Get the main Gtk struct */
44 	public GVfs* getVfsStruct()
45 	{
46 		return gVfs;
47 	}
48 
49 	/** the main Gtk struct as a void* */
50 	protected override void* getStruct()
51 	{
52 		return cast(void*)gVfs;
53 	}
54 
55 	protected override void setStruct(GObject* obj)
56 	{
57 		gVfs = cast(GVfs*)obj;
58 		super.setStruct(obj);
59 	}
60 
61 	/**
62 	 * Sets our main struct and passes it to the parent class.
63 	 */
64 	public this (GVfs* gVfs, bool ownedRef = false)
65 	{
66 		this.gVfs = gVfs;
67 		super(cast(GObject*)gVfs, ownedRef);
68 	}
69 
70 
71 	/** */
72 	public static GType getType()
73 	{
74 		return g_vfs_get_type();
75 	}
76 
77 	/**
78 	 * Gets the default #GVfs for the system.
79 	 *
80 	 * Return: a #GVfs.
81 	 */
82 	public static Vfs getDefault()
83 	{
84 		auto p = g_vfs_get_default();
85 		
86 		if(p is null)
87 		{
88 			return null;
89 		}
90 		
91 		return ObjectG.getDObject!(Vfs)(cast(GVfs*) p);
92 	}
93 
94 	/**
95 	 * Gets the local #GVfs for the system.
96 	 *
97 	 * Return: a #GVfs.
98 	 */
99 	public static Vfs getLocal()
100 	{
101 		auto p = g_vfs_get_local();
102 		
103 		if(p is null)
104 		{
105 			return null;
106 		}
107 		
108 		return ObjectG.getDObject!(Vfs)(cast(GVfs*) p);
109 	}
110 
111 	/**
112 	 * Gets a #GFile for @path.
113 	 *
114 	 * Params:
115 	 *     path = a string containing a VFS path.
116 	 *
117 	 * Return: a #GFile.
118 	 *     Free the returned object with g_object_unref().
119 	 */
120 	public FileIF getFileForPath(string path)
121 	{
122 		auto p = g_vfs_get_file_for_path(gVfs, Str.toStringz(path));
123 		
124 		if(p is null)
125 		{
126 			return null;
127 		}
128 		
129 		return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true);
130 	}
131 
132 	/**
133 	 * Gets a #GFile for @uri.
134 	 *
135 	 * This operation never fails, but the returned object
136 	 * might not support any I/O operation if the URI
137 	 * is malformed or if the URI scheme is not supported.
138 	 *
139 	 * Params:
140 	 *     uri = a string containing a URI
141 	 *
142 	 * Return: a #GFile.
143 	 *     Free the returned object with g_object_unref().
144 	 */
145 	public FileIF getFileForUri(string uri)
146 	{
147 		auto p = g_vfs_get_file_for_uri(gVfs, Str.toStringz(uri));
148 		
149 		if(p is null)
150 		{
151 			return null;
152 		}
153 		
154 		return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true);
155 	}
156 
157 	/**
158 	 * Gets a list of URI schemes supported by @vfs.
159 	 *
160 	 * Return: a %NULL-terminated array of strings.
161 	 *     The returned array belongs to GIO and must
162 	 *     not be freed or modified.
163 	 */
164 	public string[] getSupportedUriSchemes()
165 	{
166 		return Str.toStringArray(g_vfs_get_supported_uri_schemes(gVfs));
167 	}
168 
169 	/**
170 	 * Checks if the VFS is active.
171 	 *
172 	 * Return: %TRUE if construction of the @vfs was successful
173 	 *     and it is now active.
174 	 */
175 	public bool isActive()
176 	{
177 		return g_vfs_is_active(gVfs) != 0;
178 	}
179 
180 	/**
181 	 * This operation never fails, but the returned object might
182 	 * not support any I/O operations if the @parse_name cannot
183 	 * be parsed by the #GVfs module.
184 	 *
185 	 * Params:
186 	 *     parseName = a string to be parsed by the VFS module.
187 	 *
188 	 * Return: a #GFile for the given @parse_name.
189 	 *     Free the returned object with g_object_unref().
190 	 */
191 	public FileIF parseName(string parseName)
192 	{
193 		auto p = g_vfs_parse_name(gVfs, Str.toStringz(parseName));
194 		
195 		if(p is null)
196 		{
197 			return null;
198 		}
199 		
200 		return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true);
201 	}
202 }