[LINUX][OSX] Abstract platform log opening routine.
authoralthekiller <althekiller@xbmc.org>
Sun, 6 Feb 2011 23:56:51 +0000 (18:56 -0500)
committeralthekiller <althekiller@xbmc.org>
Thu, 10 Feb 2011 01:15:37 +0000 (20:15 -0500)
XBMC.xcodeproj/project.pbxproj
xbmc/linux/stat_utf8.h [new file with mode: 0644]
xbmc/linux/stdio_utf8.h [new file with mode: 0644]
xbmc/utils/log.cpp

index 4ae9930..13d3576 100644 (file)
 
 /* Begin PBXFileReference section */
                09AB6884FE841BABC02AAC07 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
+               18308CB41303370800AA309E /* stat_utf8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stat_utf8.h; sourceTree = "<group>"; };
+               18308CB51303370800AA309E /* stdio_utf8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stdio_utf8.h; sourceTree = "<group>"; };
                183FDF8811AF0B0500B81E9C /* PluginSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginSource.cpp; sourceTree = "<group>"; };
                183FDF8911AF0B0500B81E9C /* PluginSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginSource.h; sourceTree = "<group>"; };
                184C472D1296BC6E0006DB3E /* Service.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Service.cpp; sourceTree = "<group>"; };
                E38E1D690D25F9FD00618676 /* linux */ = {
                        isa = PBXGroup;
                        children = (
+                               18308CB41303370800AA309E /* stat_utf8.h */,
+                               18308CB51303370800AA309E /* stdio_utf8.h */,
                                E3D87AE90D3182F4000CF031 /* XCriticalSection.cpp */,
                                E3D87AEA0D3182F4000CF031 /* XCriticalSection.h */,
                                E38E1D6A0D25F9FD00618676 /* ConvUtils.cpp */,
diff --git a/xbmc/linux/stat_utf8.h b/xbmc/linux/stat_utf8.h
new file mode 100644 (file)
index 0000000..047c8f1
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ *      Copyright (C) 2005-2011 Team XBMC
+ *      http://www.xbmc.org
+ *
+ *  This Program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This Program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with XBMC; see the file COPYING.  If not, write to
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *  http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#ifndef STAT_UTF8_H__
+#define STAT_UTF8_H__
+
+#define stat64_utf8 stat64
+
+#endif //STAT_UTF8_H__
+
diff --git a/xbmc/linux/stdio_utf8.h b/xbmc/linux/stdio_utf8.h
new file mode 100644 (file)
index 0000000..344db2a
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ *      Copyright (C) 2005-2011 Team XBMC
+ *      http://www.xbmc.org
+ *
+ *  This Program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This Program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with XBMC; see the file COPYING.  If not, write to
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *  http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#ifndef STDIO_UTF8_H__
+#define STDIO_UTF8_H__
+
+#include <cstdio>
+
+#define remove_utf8     remove
+#define rename_utf8     rename
+#define fopen64_utf8    fopen
+
+#endif // STDIO_UTF8_H__
+
index a6777af..dda3d0f 100644 (file)
@@ -24,6 +24,9 @@
 #ifndef _LINUX
 #include <share.h>
 #include "CharsetConverter.h"
+#else
+#include "stdio_utf8.h"
+#include "stat_utf8.h"
 #endif
 #include "threads/CriticalSection.h"
 #include "threads/SingleLock.h"
@@ -161,14 +164,14 @@ bool CLog::Init(const char* path)
     strLogFileOld.Format("%sxbmc.old.log", path);
 
     struct stat64 info;
-    if (stat64(strLogFileOld.c_str(),&info) == 0 &&
-        remove(strLogFileOld.c_str()) != 0)
+    if (stat64_utf8(strLogFileOld.c_str(),&info) == 0 &&
+        remove_utf8(strLogFileOld.c_str()) != 0)
       return false;
-    if (stat64(strLogFile.c_str(),&info) == 0 &&
-        rename(strLogFile.c_str(),strLogFileOld.c_str()) != 0)
+    if (stat64_utf8(strLogFile.c_str(),&info) == 0 &&
+        rename_utf8(strLogFile.c_str(),strLogFileOld.c_str()) != 0)
       return false;
 
-    m_file = fopen(strLogFile.c_str(),"wb");
+    m_file = fopen64_utf8(strLogFile.c_str(),"wb");
 #endif
   }