* Copyright (C) 1998-1999 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
+ * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
- * Modified by the GLib Team and others 1997-1999. See the AUTHORS
+ * Modified by the GLib Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GLib Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GLib at ftp://ftp.gtk.org/pub/gtk/.
if (k && result->dir_name[k - 1] == '\\')
{
result->dir_name[k - 1] = '\0';
- k--;
}
mask = g_strdup_printf ("%s\\*", result->dir_name);
struct dirent*
g_win32_readdir (DIR *dir)
{
- static struct dirent result;
+ gchar *basename;
g_return_val_if_fail (dir != NULL, NULL);
}
}
}
- strcpy (result.d_name, g_basename (((LPWIN32_FIND_DATA) dir->find_file_data)->cFileName));
+
+ basename = g_path_get_basename (((LPWIN32_FIND_DATA) dir->find_file_data)->cFileName);
+
+ strcpy (dir->readdir_result.d_name, basename);
+
+ g_free (basename);
- return &result;
+ return &dir->readdir_result;
}
void
gchar *
g_win32_getlocale (void)
{
- LCID lcid = GetThreadLocale ();
+ LCID lcid;
+ gchar *ev;
gint primary, sub;
gchar *l = NULL, *sl = NULL;
gchar bfr[20];
+ if ((ev = getenv ("LC_ALL")) != NULL
+ || (ev = getenv ("LC_CTYPE")) != NULL
+ || (ev = getenv ("LANG")) != NULL)
+ return g_strdup (ev);
+
+ lcid = GetThreadLocale ();
primary = PRIMARYLANGID (LANGIDFROMLCID (lcid));
sub = SUBLANGID (LANGIDFROMLCID (lcid));
switch (primary)
*/
switch (sub)
{
- case SUBLANG_SERBIAN_LATIN: l = "hr"; break;
+ case SUBLANG_SERBIAN_LATIN: l = "sp"; break;
case SUBLANG_SERBIAN_CYRILLIC: l = "sr"; break;
default: l = "hr"; /* ??? */
}
l = "en";
switch (sub)
{
- case SUBLANG_ENGLISH_US: sl = "US"; break;
+ /* SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. Heh. I thought
+ * English was the language spoken in England.
+ * Oh well.
+ */
case SUBLANG_ENGLISH_UK: sl = "GB"; break;
case SUBLANG_ENGLISH_AUS: sl = "AU"; break;
case SUBLANG_ENGLISH_CAN: sl = "CA"; break;
l = "ms";
switch (sub)
{
- case SUBLANG_MALAY_MALAYSIA: sl = "MY"; break;
case SUBLANG_MALAY_BRUNEI_DARUSSALAM: sl = "BN"; break;
}
break;
l = "no";
switch (sub)
{
- case SUBLANG_NORWEGIAN_BOKMAL: sl = "@bokmal"; break;
+ /* SUBLANG_NORWEGIAN_BOKMAL == SUBLANG_DEFAULT */
case SUBLANG_NORWEGIAN_NYNORSK: sl = "@nynorsk"; break;
}
break;
l = "pt";
switch (sub)
{
+ /* Hmm. SUBLANG_PORTUGUESE_BRAZILIAN == SUBLANG_DEFAULT */
case SUBLANG_PORTUGUESE_BRAZILIAN: sl = "BR"; break;
}
break;
l = "uz";
switch (sub)
{
- case SUBLANG_UZBEK_LATIN: sl = "2latin"; break;
case SUBLANG_UZBEK_CYRILLIC: sl = "@cyrillic"; break;
}
break;
return g_strdup (bfr);
}
+
+gchar *
+g_win32_error_message (gint error)
+{
+ gchar *msg;
+ gchar *retval;
+ int nbytes;
+
+ FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER
+ |FORMAT_MESSAGE_IGNORE_INSERTS
+ |FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL, error, 0,
+ (LPTSTR) &msg, 0, NULL);
+ nbytes = strlen (msg);
+
+ if (nbytes > 2 && msg[nbytes-1] == '\n' && msg[nbytes-2] == '\r')
+ msg[nbytes-2] = '\0';
+
+ retval = g_strdup (msg);
+
+ if (msg != NULL)
+ LocalFree (msg);
+
+ return retval;
+}