]> git.cworth.org Git - apitrace/commitdiff
Prepend process name to the log's filename.
authorJosé Fonseca <jfonseca@vmware.com>
Thu, 3 Sep 2009 10:21:09 +0000 (11:21 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Thu, 3 Sep 2009 10:21:09 +0000 (11:21 +0100)
log.cpp

diff --git a/log.cpp b/log.cpp
index 433368f1c23ed414ec7a195f3d21efcaad1cee3f..7e219700988acad8e12ba6f0324885aa49a193f1 100644 (file)
--- a/log.cpp
+++ b/log.cpp
@@ -63,13 +63,25 @@ static void _Open(const char *szName, const char *szExtension) {
     
     static unsigned dwCounter = 0;
 
+    char szProcessPath[PATH_MAX];
+    char *lpProcessName;
+    char *lpProcessExt;
+
+    GetModuleFileNameA(NULL, szProcessPath, sizeof(szProcessPath)/sizeof(szProcessPath[0]));
+
+    lpProcessName = strrchr(szProcessPath, '\\');
+    lpProcessName = lpProcessName ? lpProcessName + 1 : szProcessPath;
+    lpProcessExt = strrchr(lpProcessName, '.');
+    if(lpProcessExt)
+       *lpProcessExt = '\0';
+
     for(;;) {
         FILE *file;
         
         if(dwCounter)
-            snprintf(g_szFileName, PATH_MAX, "%s.%u.%s.gz", szName, dwCounter, szExtension);
+            snprintf(g_szFileName, PATH_MAX, "%s.%s.%u.%s.gz", lpProcessName, szName, dwCounter, szExtension);
         else
-            snprintf(g_szFileName, PATH_MAX, "%s.%s.gz", szName, szExtension);
+            snprintf(g_szFileName, PATH_MAX, "%s.%s.%s.gz", lpProcessName, szName, szExtension);
         
         file = fopen(g_szFileName, "rb");
         if(file == NULL)