Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 /*
6 * Internal libjar routines.
7 */
9 #include "jar.h"
10 #include "jarint.h"
12 /*-----------------------------------------------------------------------
13 * JAR_FOPEN_to_PR_Open
14 * Translate JAR_FOPEN arguments to PR_Open arguments
15 */
16 PRFileDesc*
17 JAR_FOPEN_to_PR_Open(const char* name, const char *mode)
18 {
20 PRIntn prflags=0, prmode=0;
22 /* Get read/write flags */
23 if (strchr(mode, 'r') && !strchr(mode, '+')) {
24 prflags |= PR_RDONLY;
25 } else if( (strchr(mode, 'w') || strchr(mode, 'a')) &&
26 !strchr(mode,'+') ) {
27 prflags |= PR_WRONLY;
28 } else {
29 prflags |= PR_RDWR;
30 }
32 /* Create a new file? */
33 if (strchr(mode, 'w') || strchr(mode, 'a')) {
34 prflags |= PR_CREATE_FILE;
35 }
37 /* Append? */
38 if (strchr(mode, 'a')) {
39 prflags |= PR_APPEND;
40 }
42 /* Truncate? */
43 if (strchr(mode, 'w')) {
44 prflags |= PR_TRUNCATE;
45 }
47 /* We can't do umask because it isn't XP. Choose some default
48 mode for created files */
49 prmode = 0755;
51 return PR_Open(name, prflags, prmode);
52 }