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 
73 	public static GType getType()
74 	{
75 		return g_vfs_get_type();
76 	}
77 
78 	/**
79 	 * Gets the default #GVfs for the system.
80 	 *
81 	 * Return: a #GVfs.
82 	 */
83 	public static Vfs getDefault()
84 	{
85 		auto p = g_vfs_get_default();
86 		
87 		if(p is null)
88 		{
89 			return null;
90 		}
91 		
92 		return ObjectG.getDObject!(Vfs)(cast(GVfs*) p);
93 	}
94 
95 	/**
96 	 * Gets the local #GVfs for the system.
97 	 *
98 	 * Return: a #GVfs.
99 	 */
100 	public static Vfs getLocal()
101 	{
102 		auto p = g_vfs_get_local();
103 		
104 		if(p is null)
105 		{
106 			return null;
107 		}
108 		
109 		return ObjectG.getDObject!(Vfs)(cast(GVfs*) p);
110 	}
111 
112 	/**
113 	 * Gets a #GFile for @path.
114 	 *
115 	 * Params:
116 	 *     path = a string containing a VFS path.
117 	 *
118 	 * Return: a #GFile.
119 	 *     Free the returned object with g_object_unref().
120 	 */
121 	public FileIF getFileForPath(string path)
122 	{
123 		auto p = g_vfs_get_file_for_path(gVfs, Str.toStringz(path));
124 		
125 		if(p is null)
126 		{
127 			return null;
128 		}
129 		
130 		return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p);
131 	}
132 
133 	/**
134 	 * Gets a #GFile for @uri.
135 	 *
136 	 * This operation never fails, but the returned object
137 	 * might not support any I/O operation if the URI
138 	 * is malformed or if the URI scheme is not supported.
139 	 *
140 	 * Params:
141 	 *     uri = a string containing a URI
142 	 *
143 	 * Return: a #GFile.
144 	 *     Free the returned object with g_object_unref().
145 	 */
146 	public FileIF getFileForUri(string uri)
147 	{
148 		auto p = g_vfs_get_file_for_uri(gVfs, Str.toStringz(uri));
149 		
150 		if(p is null)
151 		{
152 			return null;
153 		}
154 		
155 		return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p);
156 	}
157 
158 	/**
159 	 * Gets a list of URI schemes supported by @vfs.
160 	 *
161 	 * Return: a %NULL-terminated array of strings.
162 	 *     The returned array belongs to GIO and must
163 	 *     not be freed or modified.
164 	 */
165 	public string[] getSupportedUriSchemes()
166 	{
167 		return Str.toStringArray(g_vfs_get_supported_uri_schemes(gVfs));
168 	}
169 
170 	/**
171 	 * Checks if the VFS is active.
172 	 *
173 	 * Return: %TRUE if construction of the @vfs was successful
174 	 *     and it is now active.
175 	 */
176 	public bool isActive()
177 	{
178 		return g_vfs_is_active(gVfs) != 0;
179 	}
180 
181 	/**
182 	 * This operation never fails, but the returned object might
183 	 * not support any I/O operations if the @parse_name cannot
184 	 * be parsed by the #GVfs module.
185 	 *
186 	 * Params:
187 	 *     parseName = a string to be parsed by the VFS module.
188 	 *
189 	 * Return: a #GFile for the given @parse_name.
190 	 *     Free the returned object with g_object_unref().
191 	 */
192 	public FileIF parseName(string parseName)
193 	{
194 		auto p = g_vfs_parse_name(gVfs, Str.toStringz(parseName));
195 		
196 		if(p is null)
197 		{
198 			return null;
199 		}
200 		
201 		return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p);
202 	}
203 }