]> git.lyx.org Git - features.git/commitdiff
Add Windows-specific code to userinfo.C.
authorAngus Leeming <leeming@lyx.org>
Sun, 24 Apr 2005 12:21:57 +0000 (12:21 +0000)
committerAngus Leeming <leeming@lyx.org>
Sun, 24 Apr 2005 12:21:57 +0000 (12:21 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9869 a592a061-630c-0410-9148-cb99ea01b6c8

development/Win32/win32_kludge.diff
src/support/ChangeLog
src/support/userinfo.C

index 9511d54e8e36a592b890c0d7bf7026a97c4b9b10..e1416f291ee64eefc9e42efef85ad6d8a42a6f3b 100644 (file)
@@ -568,39 +568,3 @@ diff -u -a -u -r1.25 tempname.C
                lyxerr[Debug::FILES] << "Temporary file `" << t
                                     << "' created." << endl;
                return t;
-Index: src/support/userinfo.C
-===================================================================
-RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/userinfo.C,v
-retrieving revision 1.10
-diff -u -a -u -r1.10 userinfo.C
---- src/support/userinfo.C     15 Feb 2005 13:45:41 -0000      1.10
-+++ src/support/userinfo.C     19 Apr 2005 08:09:40 -0000
-@@ -15,7 +15,9 @@
- #include <boost/assert.hpp>
--#include <pwd.h>
-+#ifndef _WIN32
-+# include <pwd.h>
-+#endif
- #ifdef HAVE_UNISTD_H
- # include <unistd.h>
- #endif
-@@ -28,6 +30,7 @@
- string const user_name()
- {
-+#ifndef _WIN32
-       struct passwd * pw(getpwuid(geteuid()));
-       BOOST_ASSERT(pw);
-@@ -35,6 +38,9 @@
-       if (name.empty())
-               name = pw->pw_name;
-       return name;
-+#else
-+      return "dummy";
-+#endif
- }
index faa382ca9e012b5a301c38946bf34597ab1ee57e..19ab70f77cedb30ecb3b9027ebb97b4a0ed664af 100644 (file)
@@ -1,3 +1,7 @@
+2005-04-24  Angus Leeming  <leeming@lyx.org>
+
+       * userinfo.C (user_name): add Windows-specific code.
+
 2005-04-22  Angus Leeming  <leeming@lyx.org>
 
        * package.C.in (get_binary_path): on prompting from Rob Bearman,
index 758ce34572a9e0e8f755ec938a66c5989fc2c01f..6203ef598330e74211a432eb057c7b06ebb7cd27 100644 (file)
 
 #include <boost/assert.hpp>
 
-#include <pwd.h>
-#ifdef HAVE_UNISTD_H
+#if defined (_WIN32)
+# include "gettext.h"
+# include <lmcons.h>
+# include <windows.h>
+#else
+# include <pwd.h>
 # include <unistd.h>
 #endif
 #include <sys/types.h>
@@ -28,6 +32,14 @@ namespace support {
 
 string const user_name()
 {
+#if defined (_WIN32)
+
+       char name[UNLEN + 1];
+       DWORD size = UNLEN + 1;
+       if (!GetUserName(name, &size))
+               return _("Unknown user");
+       return name;
+#else
        struct passwd * pw(getpwuid(geteuid()));
        BOOST_ASSERT(pw);
 
@@ -35,6 +47,7 @@ string const user_name()
        if (name.empty())
                name = pw->pw_name;
        return name;
+#endif
 }