From 9aebee2a28dcf650a87603441dd74098c46f7eb5 Mon Sep 17 00:00:00 2001
From: Pankaj Yadav <pk@videolan.org>
Date: Sun, 9 Jan 2011 01:25:01 +0530
Subject: [PATCH 1/4] Symbian Applications Directory for private path

---
 src/symbian/path.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/symbian/path.h |   31 +++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+), 0 deletions(-)
 create mode 100755 src/symbian/path.c
 create mode 100755 src/symbian/path.h

diff --git a/src/symbian/path.c b/src/symbian/path.c
new file mode 100755
index 0000000..60cbfd7
--- /dev/null
+++ b/src/symbian/path.c
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * Symbian_Path.cpp: 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 "path.h"
+
+/*Way to Find AppPrivatePath (A Path where an application can store its private data) */
+TInt GetPrivatePath(TFileName& privatePath)
+{
+    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()
+{
+    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 );
+    /*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';}
+    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>
+
+TInt GetPrivatePath(TFileName &);
+char * GetConstPrivatePath();
+
-- 
1.7.1

