]> git.vomp.tv Git - vompserver.git/commitdiff
Fix for moving recordings
authorChris Tallon <chris@vomp.tv>
Wed, 2 Apr 2008 17:24:00 +0000 (17:24 +0000)
committerChris Tallon <chris@vomp.tv>
Wed, 2 Apr 2008 17:24:00 +0000 (17:24 +0000)
log.c
mvpclient.c

diff --git a/log.c b/log.c
index c1f7445908e4468c576819b98d4a33e03b936ca7..12be43e90c85d3bc02f8a67ba1333a8252d1cbaf 100755 (executable)
--- a/log.c
+++ b/log.c
@@ -100,14 +100,16 @@ int Log::log(const char *fromModule, int level, const char* message, ...)
 
   if (level > logLevel) return 1;
 
-  char buffer[151];
-  int spaceLeft = 150;
+  int lineLength = 250;
+
+  char buffer[lineLength + 1];
+  int spaceLeft = lineLength;
 
   struct timeval tv;
   gettimeofday(&tv, NULL);
   struct tm* tm = localtime(&tv.tv_sec);
   spaceLeft -= strftime(buffer, spaceLeft, "%H:%M:%S.", tm);
-  spaceLeft -= snprintf(&buffer[150-spaceLeft], spaceLeft, "%06lu ", (unsigned long)tv.tv_usec);
+  spaceLeft -= snprintf(&buffer[lineLength-spaceLeft], spaceLeft, "%06lu ", (unsigned long)tv.tv_usec);
 
 
   char levelString[10];
@@ -121,23 +123,23 @@ int Log::log(const char *fromModule, int level, const char* message, ...)
   if (level == INFO)    strcpy(levelString, "[info]  ");
   if (level == DEBUG)   strcpy(levelString, "[debug] ");
 
-  spaceLeft -= snprintf(&buffer[150-spaceLeft], spaceLeft, "%s %s - ", levelString, fromModule);
+  spaceLeft -= snprintf(&buffer[lineLength-spaceLeft], spaceLeft, "%s %s - ", levelString, fromModule);
 
   va_list ap;
   va_start(ap, message);
-  spaceLeft = vsnprintf(&buffer[150-spaceLeft], spaceLeft, message, ap);
+  spaceLeft = vsnprintf(&buffer[lineLength-spaceLeft], spaceLeft, message, ap);
   va_end(ap);
 
   int messageLength = strlen(buffer);
-  if (messageLength < 150)
+  if (messageLength < lineLength)
   {
     buffer[messageLength] = '\n';
     buffer[messageLength+1] = '\0';
   }
   else
   {
-    buffer[149] = '\n';
-    buffer[150] = '\0';
+    buffer[lineLength-1] = '\n';
+    buffer[lineLength] = '\0';
   }
 
   int success = fputs(buffer, logfile);
index 40449f4e729f1bc1202b2365f0d17ffaf4420519..cad8345a1b765c1c8723180aee0715268eec83e6 100644 (file)
@@ -566,18 +566,20 @@ int MVPClient::processMoveRecording(UCHAR* data, int length, ResponsePacket* rp)
 
       log->log("Client", Log::DEBUG, "datedirname: %s", dateDirName);
       log->log("Client", Log::DEBUG, "titledirname: %s", titleDirName);
-
       log->log("Client", Log::DEBUG, "viddir: %s", VideoDirectory);
 
-      char* newContainer = new char[strlen(VideoDirectory) + strlen(newPath) + strlen(titleDirName) + 1];
-      log->log("Client", Log::DEBUG, "l10: %i", strlen(VideoDirectory) + strlen(newPath) + strlen(titleDirName) + 1);
-      sprintf(newContainer, "%s%s%s", VideoDirectory, newPath, titleDirName);
+      char* newPathConv = new char[strlen(newPath)+1];
+      strcpy(newPathConv, newPath);
+      ExchangeChars(newPathConv, true);
+      log->log("Client", Log::DEBUG, "EC: %s", newPathConv);
 
-      // FIXME Check whether this already exists before mkdiring it
+      char* newContainer = new char[strlen(VideoDirectory) + strlen(newPathConv) + strlen(titleDirName) + 1];
+      log->log("Client", Log::DEBUG, "l10: %i", strlen(VideoDirectory) + strlen(newPathConv) + strlen(titleDirName) + 1);
+      sprintf(newContainer, "%s%s%s", VideoDirectory, newPathConv, titleDirName);
+      delete[] newPathConv;
 
       log->log("Client", Log::DEBUG, "%s", newContainer);
 
-
       struct stat dstat;
       int statret = stat(newContainer, &dstat);
       if ((statret == -1) && (errno == ENOENT)) // Dir does not exist