CVS: winex/files directory.c,1.24,1.25
[email protected] 31 Jul 2007 17:33:16 -0000
| Newsgroups | gmane.comp.emulators.winex.cvs |
|---|---|
| Message-ID | <[email protected]> |
Subject: winex/files directory.c,1.24,1.25Update of /var/lib/cvsd/cvsroot/winex/files
In directory agravaine:/tmp/cvs-serv20941/files
Modified Files:
directory.c
Log Message:
- place temp files in <temp>/tg-user/ to avoid conflicts between users
Index: directory.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/files/directory.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- directory.c 22 Feb 2007 23:30:28 -0000 1.24
+++ directory.c 31 Jul 2007 17:33:14 -0000 1.25
@@ -17,6 +17,9 @@
# include <sys/stat.h>
#endif
#include <unistd.h>
+#ifdef HAVE_UTMP_H
+#include <utmp.h>
+#endif
#include <errno.h>
#include <limits.h>
#ifdef HAVE_SYS_ERRNO_H
@@ -71,6 +74,76 @@
/***********************************************************************
+ * DIR_GetTempPath
+ *
+ * Get the temp path name from the wine.ini file and make sure it is valid.
+ */
+static int DIR_GetTempPath (const char *defval, DOS_FULL_NAME *full_name,
+ char * longname, BOOL warn)
+{
+ char path[MAX_PATHNAME_LEN];
+ BY_HANDLE_FILE_INFORMATION info;
+ const char *mess = "does not exist";
+ size_t len;
+#if defined(HAVE_UTMP_H) && defined(HAVE_GETLOGIN_R)
+ char userBuf[UT_NAMESIZE + 1];
+#endif
+ char *pUserName;
+
+ PROFILE_GetWineIniString ("wine", "temp", defval, path, sizeof (path));
+ len = strlen (path);
+
+ /* Add the username to the end so that there won't be any conflicts */
+
+ /* Ensure it ends with a \\ */
+ if (len && (path[len - 1] != '\\') && ((len + 1) < sizeof (path)))
+ {
+ path[len] = '\\';
+ path[len + 1] = '\0';
+ }
+
+ /* Append username */
+ pUserName = getenv ("LOGNAME");
+#if defined(HAVE_UTMP_H) && defined(HAVE_GETLOGIN_R)
+ if (!pUserName &&
+ (getlogin_r (userBuf, sizeof (userBuf)) == 0))
+ pUserName = userBuf;
+#endif
+
+ len = strlen (path);
+ if (pUserName && ((len + strlen (pUserName) + 4) < sizeof (path)))
+ {
+ strcat (path + len, "tg-");
+ strcat (path + len + 3, pUserName);
+ }
+
+ if (!DOSFS_GetFullName (path, FALSE, full_name))
+ {
+ if (warn)
+ MESSAGE ("Invalid path '%s' for temp directory: %s\n", path, mess);
+ return 0;
+ }
+
+ /* Create it if it doesn't exist; ignore failure (as it may well exist) */
+ mkdir (full_name->long_name, S_IRWXU);
+
+ if ((!FILE_Stat (full_name->long_name, &info) &&
+ (mess = strerror (errno))) ||
+ (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
+ (mess = "not a directory")) ||
+ !GetLongPathNameA (full_name->short_name, longname,
+ MAX_PATHNAME_LEN))
+ {
+ if (warn)
+ MESSAGE ("Invalid path '%s' for temp directory: %s\n", path, mess);
+ return 0;
+ }
+
+ return 1;
+}
+
+
+/***********************************************************************
* DIR_Init
*/
int DIR_Init(void)
@@ -189,7 +262,7 @@
if (!(DIR_GetPath( "windows", "c:\\windows", &DIR_Windows, longpath, TRUE )) ||
!(DIR_GetPath( "system", "c:\\windows\\system", &DIR_System, longpath, TRUE )) ||
- !(DIR_GetPath( "temp", "c:\\windows", &tmp_dir, longpath, TRUE )))
+ !(DIR_GetTempPath( "c:\\windows", &tmp_dir, longpath, TRUE )))
{
PROFILE_UsageWineIni();
return 0;