|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept id="GUID-3314123F-205D-5E05-9041-DB9836B7812B" xml:lang="en"><title>File |
|
13 Access Example: Accessing the File System Using P.I.P.S.</title><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
14 <p>This example application shows, using a P.I.P.S. (P.I.P.S. Is POSIX on |
|
15 Symbian platform) program, the restrictions on file access that are imposed |
|
16 by the Symbian platform Security model. </p> |
|
17 <p>It shows that programs can access their own directories, but cannot, without |
|
18 platform security capabilities not available to ordinary programs, access |
|
19 the directories of other programs, or the system binary directory <filepath>sys/bin</filepath>. </p> |
|
20 <p>This example defines an executable file with no platform security capabilities. |
|
21 The program first creates its own secure directory that it can write to and |
|
22 read from. It then attempts to use a file in a private directory of another |
|
23 program, and then in <filepath>sys/bin</filepath>, and shows that these attempts |
|
24 are denied. </p> |
|
25 <section><title>Download</title> <p>Click on the following link to download |
|
26 the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-2dae3cca-f112-4219-8f7c-6c48682d1f28.zip" scope="external">FileAccessExample.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-2dae3cca-f112-4219-8f7c-6c48682d1f28.html" scope="peer">browse</xref> to view the example code. </p> </section> |
|
27 <section><title>Description</title> <p>The following sections provide more |
|
28 information about the steps that the example performs. </p> <p><b> Create |
|
29 a secure directory</b> </p> <p>The example creates an empty secure directory |
|
30 for the program by using the <xref href="GUID-5EA72F64-E826-3B15-9468-902BD57F6AA7.dita"><apiname>mkdir()</apiname></xref> function. </p> <p>This |
|
31 empty secure directory is created in <filepath>C:\private\E80000C9</filepath>, |
|
32 as 0xE80000C9 is a unique identifier for the program (as specified by the |
|
33 third UID in its project file). </p></section> |
|
34 <section> <p><b>Write and read a file in the private directory </b> </p> <p>The |
|
35 example writes and reads a file in the secure directory using the <xref href="GUID-64886CC6-072F-3542-855A-5D733FC761E8.dita"><apiname>fopen()</apiname></xref> and |
|
36 other file stream functions. </p> <p><b> Write and read a file in the private |
|
37 directory of another program </b> </p> <p>The example attempts to write and |
|
38 read a file in the secure directory of another program. </p> <p>The <xref href="GUID-64886CC6-072F-3542-855A-5D733FC761E8.dita"><apiname>fopen()</apiname></xref> function |
|
39 is expected to return <codeph>NULL</codeph>, indicating that access is not |
|
40 possible, as the program has insufficient platform security capabilities. </p><p><b> Write |
|
41 and read a file in the sys/bin directory</b> </p> <p>The example attempts |
|
42 to write and read a file in the system's <filepath>sys/bin</filepath> directory, |
|
43 where program binaries are stored. </p> <p>Again, the <xref href="GUID-64886CC6-072F-3542-855A-5D733FC761E8.dita"><apiname>fopen()</apiname></xref> function |
|
44 is expected to return <codeph>NULL</codeph>, indicating that access is not |
|
45 possible, as the program has insufficient platform security capabilities. </p> </section> |
|
46 <section><title>Releated APIs</title><p><xref href="GUID-5EA72F64-E826-3B15-9468-902BD57F6AA7.dita"><apiname>mkdir()</apiname></xref></p><p><xref href="GUID-64886CC6-072F-3542-855A-5D733FC761E8.dita"><apiname>fopen()</apiname></xref></p></section> |
|
47 <section><title>Build</title> <p>The <xref href="GUID-3100800B-B2F7-50EF-BD4C-3C345ECCB2A5.dita">Symbian |
|
48 platform build process</xref> describes how to build this example application. </p> <p>The |
|
49 example builds an executable called <filepath>fileaccessexample.exe</filepath> in |
|
50 the standard locations. </p> <p>To run the example, start <filepath>fileaccessexample.exe</filepath> from |
|
51 the file system or from your IDE. After launching the executable, depending |
|
52 on the emulator you are using, you may need to navigate away from the application |
|
53 launcher or shell screen to view the console. </p> </section> |
|
54 </conbody></concept> |