From 2497877632a2870eb7762b58a47162f2ada4963d Mon Sep 17 00:00:00 2001
From: Pankaj Yadav <pk@videolan.org>
Date: Sat, 8 Jan 2011 20:50:22 +0530
Subject: [PATCH 2/4] Symbian Specific Pathnames

---
 src/symbian/path.cpp |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/symbian/path.h   |   29 +++++++++++++++++++++++++
 2 files changed, 87 insertions(+), 0 deletions(-)
 create mode 100755 src/symbian/path.cpp
 create mode 100755 src/symbian/path.h

diff --git a/src/symbian/path.cpp b/src/symbian/path.cpp
new file mode 100755
index 0000000..e59a23c
--- /dev/null
+++ b/src/symbian/path.cpp
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ * 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;
+	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..1f2265b
--- /dev/null
+++ b/src/symbian/path.h
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * 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

