changeset 34696:a1785afaedef

(w32_strerror): New function.
author Andrew Innes <andrewi@gnu.org>
date Mon, 18 Dec 2000 23:50:26 +0000
parents 64dfbe3c76d5
children ba9de1745e36
files src/w32.c
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/w32.c	Mon Dec 18 18:17:59 2000 +0000
+++ b/src/w32.c	Mon Dec 18 23:50:26 2000 +0000
@@ -97,6 +97,25 @@
 extern Lisp_Object Vw32_get_true_file_attributes;
 extern Lisp_Object Vw32_num_mouse_buttons;
 
+
+/* Equivalent of strerror for W32 error codes.  */
+char *
+w32_strerror (int error_no)
+{
+  static char buf[500];
+
+  if (error_no == 0)
+    error_no = GetLastError ();
+
+  buf[0] = '\0';
+  if (!FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL,
+		      error_no,
+		      0, /* choose most suitable language */
+		      buf, sizeof (buf), NULL))
+    sprintf (buf, "w32 error %u", error_no);
+  return buf;
+}
+
 static char startup_dir[MAXPATHLEN];
 
 /* Get the current working directory.  */