From: Andrew Innes Date: Mon, 18 Dec 2000 23:50:26 +0000 (+0000) Subject: (w32_strerror): New function. X-Git-Tag: emacs-pretest-21.0.95~414 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=18e070ac54fd583e435b2200fed805fa94a4268d;p=emacs.git (w32_strerror): New function. --- diff --git a/src/w32.c b/src/w32.c index abf2db6580b..5e9b8313ddb 100644 --- a/src/w32.c +++ b/src/w32.c @@ -97,6 +97,25 @@ extern Lisp_Object Vw32_generate_fake_inodes; 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. */