forked from videolan/vlc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpath.cpp
86 lines (74 loc) · 2.47 KB
/
path.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*****************************************************************************
* path.cpp : Symbian Application's Provate Path
*****************************************************************************
* Copyright © 2010 Pankaj Yadav
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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> /* RFs */
#include <string.h> /* strlen */
#include <utf.h> /* CnvUtfConverter */
extern "C" {
#include "path.h"
}
/*Way to Find AppPrivatePath (A Path where an application can store its private data) */
static 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;
}
extern "C" char * GetConstPrivatePath(void)
{
TFileName privatePath;
TBuf8<KMaxFileName> privatepathutf8;
size_t len;
char carray[KMaxFileName];
if (GetPrivatePath(privatePath) != KErrNone)
{
return strdup("C:\\Data\\Others");
}
CnvUtfConverter::ConvertFromUnicodeToUtf8( privatepathutf8, privatePath );
TInt index = 0;
for (index = 0; index < privatepathutf8.Length(); index++)
{
carray[index] = privatepathutf8[index];
}
carray[index] = 0;
if ((len = strnlen((const char *)carray, KMaxFileName) < KMaxFileName))
{
carray[len-1] = '\0';
return strdup((const char *)carray);
}
else
{
return strdup("C:\\Data\\Others");
}
}