Coverage Report

Created: 2022-10-31 07:00

/src/ghostpdl/base/gp_unifn.c
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (C) 2001-2021 Artifex Software, Inc.
2
   All Rights Reserved.
3
4
   This software is provided AS-IS with no warranty, either express or
5
   implied.
6
7
   This software is distributed under license and may not be copied,
8
   modified or distributed except as expressly authorized under the terms
9
   of the license contained in the file LICENSE in this distribution.
10
11
   Refer to licensing information at http://www.artifex.com or contact
12
   Artifex Software, Inc.,  1305 Grant Avenue - Suite 200, Novato,
13
   CA 94945, U.S.A., +1(415)492-9861, for further information.
14
*/
15
16
17
/* Unix-like file name syntax platform routines for Ghostscript */
18
#include "gx.h"
19
#include "gp.h"
20
#include "gpmisc.h"
21
#include "gsutil.h"
22
23
/* Define the character used for separating file names in a list. */
24
const char gp_file_name_list_separator = ':';
25
26
/* Define the string to be concatenated with the file mode */
27
/* for opening files without end-of-line conversion. */
28
#if (defined(__MINGW32__) && __MINGW32__ == 1) || (defined(__CYGWIN__) && __CYGWIN__ == 1)
29
const char* gp_fmode_binary_suffix = "b";
30
#else
31
const char* gp_fmode_binary_suffix = "";
32
#endif
33
34
35
/* Define the file modes for binary reading or writing. */
36
#if (defined(__MINGW32__) && __MINGW32__ == 1) || (defined(__CYGWIN__) && __CYGWIN__ == 1)
37
const char gp_fmode_rb[] = "rb";
38
const char gp_fmode_wb[] = "wb";
39
#else
40
const char gp_fmode_rb[] = "r";
41
const char gp_fmode_wb[] = "w";
42
#endif
43
44
/* -------------- Helpers for gp_file_name_combine_generic ------------- */
45
46
uint gp_file_name_root(const char *fname, uint len)
47
205M
{   if (len > 0 && fname[0] == '/')
48
97.8M
        return 1;
49
107M
    return 0;
50
205M
}
51
52
uint gs_file_name_check_separator(const char *fname, int len, const char *item)
53
10.9G
{   if (len > 0) {
54
10.8G
        if (fname[0] == '/')
55
2.18G
            return 1;
56
10.8G
    } else if (len < 0) {
57
80.1M
        if (fname[-1] == '/')
58
65.7M
            return 1;
59
80.1M
    }
60
8.70G
    return 0;
61
10.9G
}
62
63
bool gp_file_name_is_parent(const char *fname, uint len)
64
502M
{   return len == 2 && fname[0] == '.' && fname[1] == '.';
65
502M
}
66
67
bool gp_file_name_is_current(const char *fname, uint len)
68
494M
{   return len == 1 && fname[0] == '.';
69
494M
}
70
71
const char *gp_file_name_separator(void)
72
30.5M
{   return "/";
73
30.5M
}
74
75
const char *gp_file_name_directory_separator(void)
76
18.9M
{   return "/";
77
18.9M
}
78
79
const char *gp_file_name_parent(void)
80
0
{   return "..";
81
0
}
82
83
const char *gp_file_name_current(void)
84
24.2M
{   return ".";
85
24.2M
}
86
87
bool gp_file_name_is_parent_allowed(void)
88
8
{   return true;
89
8
}
90
91
bool gp_file_name_is_empty_item_meanful(void)
92
107k
{   return false;
93
107k
}
94
95
gp_file_name_combine_result
96
gp_file_name_combine(const char *prefix, uint plen, const char *fname, uint flen,
97
                    bool no_sibling, char *buffer, uint *blen)
98
79.5M
{
99
79.5M
    return gp_file_name_combine_generic(prefix, plen,
100
79.5M
            fname, flen, no_sibling, buffer, blen);
101
79.5M
}
102
103
bool
104
gp_file_name_good_char(unsigned char c)
105
79
{
106
79
  return c != 0 && c != '/' && c != '\\' && c != ':';
107
79
}