]> git.sesse.net Git - vlc/blob - src/symbian/path.cpp
mediacodec: don't loop in GetOutput
[vlc] / src / symbian / path.cpp
1 /*****************************************************************************
2  * path.cpp : Symbian Application's Provate Path
3  *****************************************************************************
4  * Copyright © 2010 Pankaj Yadav
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * 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.
10  *
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 Lesser General Public License for more details.
15  *
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 Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19  *****************************************************************************/
20
21 #include <f32file.h>    /* RFs */
22 #include <string.h>     /* strlen */
23 #include <utf.h>        /* CnvUtfConverter */
24
25 extern "C" {
26     #include "path.h"
27 }
28
29 /*Way to Find AppPrivatePath (A Path where an application can store its private data) */
30 static TInt GetPrivatePath(TFileName& privatePath)
31 {
32     TFileName KPath;
33     RFs fsSession;
34     TInt result;
35
36     result = fsSession.Connect();
37     if (result != KErrNone)
38     {
39         return result;
40     }
41     fsSession.PrivatePath(KPath);
42     TFindFile findFile(fsSession);
43
44     privatePath = KPath;
45     result = findFile.FindByDir(KPath, KNullDesC);
46     if (result == KErrNone)
47     {
48         privatePath = findFile.File();
49     }
50
51     fsSession.Close();
52     return result;
53 }
54
55 extern "C" char * GetConstPrivatePath(void)
56 {
57     TFileName privatePath;
58     TBuf8<KMaxFileName> privatepathutf8;
59     size_t len;
60     char carray[KMaxFileName];
61
62     if (GetPrivatePath(privatePath) != KErrNone)
63     {
64         return strdup("C:\\Data\\Others");
65     }
66
67     CnvUtfConverter::ConvertFromUnicodeToUtf8( privatepathutf8, privatePath );
68
69     TInt index = 0;
70     for (index = 0; index < privatepathutf8.Length(); index++)
71     {
72         carray[index] = privatepathutf8[index];
73     }
74     carray[index] = 0;
75
76     if ((len = strnlen((const char *)carray, KMaxFileName) < KMaxFileName))
77     {
78         carray[len-1] = '\0';
79         return strdup((const char *)carray);
80     }
81     else
82     {
83         return strdup("C:\\Data\\Others");
84     }
85 }
86