1 /*****************************************************************************
2 * path.cpp : Symbian Application's Provate Path
3 *****************************************************************************
4 * Copyright © 2010 Pankaj Yadav
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
21 #include <f32file.h> /* RFs */
22 #include <string.h> /* strlen */
23 #include <utf.h> /* CnvUtfConverter */
29 /*Way to Find AppPrivatePath (A Path where an application can store its private data) */
30 static TInt
GetPrivatePath(TFileName
& privatePath
)
36 result
= fsSession
.Connect();
37 if (result
!= KErrNone
)
41 fsSession
.PrivatePath(KPath
);
42 TFindFile
findFile(fsSession
);
45 result
= findFile
.FindByDir(KPath
, KNullDesC
);
46 if (result
== KErrNone
)
48 privatePath
= findFile
.File();
55 extern "C" char * GetConstPrivatePath(void)
57 TFileName privatePath
;
58 TBuf8
<KMaxFileName
> privatepathutf8
;
60 char carray
[KMaxFileName
];
62 if (GetPrivatePath(privatePath
) != KErrNone
)
64 return strdup("C:\\Data\\Others");
67 CnvUtfConverter::ConvertFromUnicodeToUtf8( privatepathutf8
, privatePath
);
70 for (index
= 0; index
< privatepathutf8
.Length(); index
++)
72 carray
[index
] = privatepathutf8
[index
];
76 if ((len
= strnlen((const char *)carray
, KMaxFileName
) < KMaxFileName
))
79 return strdup((const char *)carray
);
83 return strdup("C:\\Data\\Others");