alternative to assert
[gtkD.git] / src / glib / WindowsUtils.d
blob30a663ad3be26f8017ef5305b699da52ebf45695
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = glib-Windows-Compatibility-Functions.html
26 * outPack = glib
27 * outFile = WindowsUtils
28 * strct =
29 * realStrct=
30 * ctorStrct=
31 * clss = WindowsUtils
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_win32_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.Str
45 * structWrap:
46 * local aliases:
49 module glib.WindowsUtils;
51 private import glib.glibtypes;
53 private import lib.glib;
55 private import glib.Str;
57 /**
58 * Description
59 * These functions provide some level of UNIX emulation on the Windows platform.
60 * If your application really needs the POSIX APIs, we suggest you try the Cygwin
61 * project.
63 public class WindowsUtils
66 /**
71 /**
72 * Translate a Win32 error code (as returned by GetLastError()) into
73 * the corresponding message. The message is either language neutral,
74 * or in the thread's language, or the user's language, the system's
75 * language, or US English (see docs for FormatMessage()). The
76 * returned string is in UTF-8. It should be deallocated with
77 * g_free().
78 * error:
79 * error code.
80 * Returns:
81 * newly-allocated error message
83 public static char[] errorMessage(int error)
85 // gchar* g_win32_error_message (gint error);
86 return Str.toString(g_win32_error_message(error) );
89 /**
90 * The setlocale() function in the Microsoft C library uses locale
91 * names of the form "English_United States.1252" etc. We want the
92 * UNIXish standard form "en_US", "zh_TW" etc. This function gets the
93 * current thread locale from Windows - without any encoding info -
94 * and returns it as a string of the above form for use in forming
95 * file names etc. The returned string should be deallocated with
96 * g_free().
97 * Returns:
98 * newly-allocated locale name.
100 public static char[] getlocale()
102 // gchar* g_win32_getlocale (void);
103 return Str.toString(g_win32_getlocale() );
107 * Try to determine the installation directory for a software package.
108 * Typically used by GNU software packages.
109 * package should be a short identifier for the package. Typically it
110 * is the same identifier as used for
111 * GETTEXT_PACKAGE in software configured according
112 * to GNU standards. The function first looks in the Windows Registry
113 * for the value #InstallationDirectory in the key
114 * #HKLM\Software\package, and if that value
115 * exists and is a string, returns that.
116 * If package is NULL, or the above value isn't found in the
117 * Registry, but dll_name is non-NULL, it should name a DLL loaded
118 * into the current process. Typically that would be the name of the
119 * DLL calling this function, looking for its installation
120 * directory. The function then asks Windows what directory that DLL
121 * was loaded from. If that directory's last component is "bin" or
122 * "lib", the parent directory is returned, otherwise the directory
123 * itself. If that DLL isn't loaded, the function proceeds as if
124 * dll_name was NULL.
125 * If both package and dll_name are NULL, the directory from where
126 * the main executable of the process was loaded is used instead in
127 * the same way as above.
128 * package:
129 * An identifier for a software package, or NULL, in UTF-8
130 * dll_name:
131 * The name of a DLL that a package provides, or NULL, in UTF-8
132 * Returns:
133 * a string containing the installation directory for
134 * package. The string is in the GLib file name encoding, i.e. UTF-8
135 * on Windows. The return value should be freed with g_free() when not
136 * needed any longer.
138 public static char[] getPackageInstallationDirectory(char[] p, char[] dllName)
140 // gchar* g_win32_get_package_installation_directory (gchar *package, gchar *dll_name);
141 return Str.toString(g_win32_get_package_installation_directory(Str.toStringz(p), Str.toStringz(dllName)) );
145 * Returns a newly-allocated string containing the path of the
146 * subdirectory subdir in the return value from calling
147 * g_win32_get_package_installation_directory() with the package and
148 * dll_name parameters.
149 * package:
150 * An identifier for a software package, in UTF-8, or NULL
151 * dll_name:
152 * The name of a DLL that a package provides, in UTF-8, or NULL
153 * subdir:
154 * A subdirectory of the package installation directory, also in UTF-8
155 * Returns:
156 * a string containing the complete path to subdir inside
157 * the installation directory of package. The returned string is in
158 * the GLib file name encoding, i.e. UTF-8 on Windows. The return
159 * value should be freed with g_free() when no longer needed.
161 public static char[] getPackageInstallationSubdirectory(char[] p, char[] dllName, char[] subdir)
163 // gchar* g_win32_get_package_installation_subdirectory (gchar *package, gchar *dll_name, gchar *subdir);
164 return Str.toString(g_win32_get_package_installation_subdirectory(Str.toStringz(p), Str.toStringz(dllName), Str.toStringz(subdir)) );
168 * Returns version information for the Windows operating system the
169 * code is running on. See MSDN documentation for the GetVersion()
170 * function. To summarize, the most significant bit is one on Win9x,
171 * and zero on NT-based systems. Since version 2.14, GLib works only
172 * on NT-based systems, so checking whether your are running on Win9x
173 * in your own software is moot. The least significant byte is 4 on
174 * Windows NT 4, and 5 on Windows XP. Software that needs really
175 * detailled version and feature information should use Win32 API like
176 * GetVersionEx() and VerifyVersionInfo().
177 * Returns:
178 * The version information.
179 * Since 2.6
181 public static uint getWindowsVersion()
183 // guint g_win32_get_windows_version (void);
184 return g_win32_get_windows_version();
188 * Converts a filename from UTF-8 to the system codepage.
189 * On NT-based Windows, on NTFS file systems, file names are in
190 * Unicode. It is quite possible that Unicode file names contain
191 * characters not representable in the system codepage. (For instance,
192 * Greek or Cyrillic characters on Western European or US Windows
193 * installations, or various less common CJK characters on CJK Windows
194 * installations.)
195 * In such a case, and if the filename refers to an existing file, and
196 * the file system stores alternate short (8.3) names for directory
197 * entries, the short form of the filename is returned. Note that the
198 * "short" name might in fact be longer than the Unicode name if the
199 * Unicode name has very short pathname components containing
200 * non-ASCII characters. If no system codepage name for the file is
201 * possible, NULL is returned.
202 * The return value is dynamically allocated and should be freed with
203 * g_free() when no longer needed.
204 * utf8filename:
205 * a UTF-8 encoded filename.
206 * Returns:
207 * The converted filename, or NULL on conversion
208 * failure and lack of short names.
209 * Since 2.8
211 public static char[] localeFilenameFromUtf8(char[] utf8filename)
213 // gchar* g_win32_locale_filename_from_utf8 (const gchar *utf8filename);
214 return Str.toString(g_win32_locale_filename_from_utf8(Str.toStringz(utf8filename)) );