[vlc-devel] [PATCH] Symbian Application Private Path

Rémi Denis-Courmont remi at remlab.net
Sun Jan 9 18:16:04 CET 2011


@@ -0,0 +1,75 @@
+/*****************************************************************************
+ * Symbian_Path.cpp: Symbian Paths
+ 
*****************************************************************************
+ * Copyright © 2010 Pankaj Yadav

2010-2011

+ * Author: Pankaj Yadav
+ * 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 of the License, 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, 
USA.
+ 
*****************************************************************************/
+
+#include "path.h"
+
+/*Way to Find AppPrivatePath (A Path where an application can store its 
private data) */
+TInt GetPrivatePath(TFileName& privatePath)

Should this function not be static?

+{
+    TFileName KPath;
+    RFs fsSession;
+    TInt result;
+
+    result = fsSession.Connect();
+    if (result != KErrNone)
+    {
+        return result;
+    }
+    fsSession.PrivatePath(KPath);
+    TFindFile findFile(fsSession);
+
+    privatePath = KPath;
+    result = findFile.FindByDir(KPath, KNullDesC);
+    if (result == KErrNone)
+    {
+        privatePath = findFile.File();
+    }
+
+    fsSession.Close();
+    return result;
+}
+
+char * GetConstPrivatePath()

If you need to use this function from C code, you should use 'void' and 
'extern C'.

+{
+    TFileName privatePath;
+    size_t ret;
+    char carray[KMaxFileName];
+
+    if(GetPrivatePath(privatePath)!=KErrNone)
+    {
+        return strdup("C:\\Data\\Others");
+    }
+
+    ret = wcstombs(carray, (const wchar_t *)privatePath.PtrZ(), KMaxFileName 
);

Are you sure wcstombs() converts to UTF-8 on Symbian?
On Windows, it converts to the ANSI code page, IIRC.

+    /*clean the Path*/
+    int i=0;
+    while(carray[i]!='\0' && i<=KMaxFileName){i++;}
+    if(i>KMaxFileName)
+    {
+        return strdup("C:\\Data\\Others");
+    }
+    if(carray[i-1]=='\\')
+    {
+        carray[i-1]='\0';
+    }

This could be simplified a lot with strnlen().

+
+    return strdup((const char *)carray);
+}
+
diff --git a/src/symbian/path.h b/src/symbian/path.h
new file mode 100755
index 0000000..7c3b38c
--- /dev/null
+++ b/src/symbian/path.h
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ * Symbian_Path.h: Symbian Paths
+ 
*****************************************************************************
+ * Copyright © 2010 Pankaj Yadav
+ * Author: Pankaj Yadav
+ * 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 of the License, 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, 
USA.
+ 
*****************************************************************************/
+
+#include <f32file.h>
+#include <e32base.h>
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include <string.h>

Those headers should be in the .cpp file as much as possible.

+
+TInt GetPrivatePath(TFileName &);

Do you really want to export this function?

+char * GetConstPrivatePath();


-- 
Rémi Denis-Courmont
http://www.remlab.net/
http://fi.linkedin.com/in/remidenis



More information about the vlc-devel mailing list