Coverage Report

Created: 2025-06-10 07:27

/src/ghostpdl/base/gp_unifn.c
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (C) 2001-2023 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.,  39 Mesa Street, Suite 108A, San Francisco,
13
   CA 94129, USA, 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
36.9M
{   if (len > 0 && fname[0] == '/')
48
18.7M
        return 1;
49
18.2M
    return 0;
50
36.9M
}
51
52
uint gs_file_name_check_separator(const char *fname, int len, const char *item)
53
2.81G
{   if (len > 0) {
54
2.80G
        if (fname[0] == '/')
55
555M
            return 1;
56
2.80G
    } else if (len < 0) {
57
3.64M
        if (fname[-1] == '/')
58
0
            return 1;
59
3.64M
    }
60
2.25G
    return 0;
61
2.81G
}
62
63
bool gp_file_name_is_parent(const char *fname, uint len)
64
93.9M
{   return len == 2 && fname[0] == '.' && fname[1] == '.';
65
93.9M
}
66
67
bool gp_file_name_is_current(const char *fname, uint len)
68
92.7M
{   return len == 1 && fname[0] == '.';
69
92.7M
}
70
71
const char *gp_file_name_separator(void)
72
6.68M
{   return "/";
73
6.68M
}
74
75
const char *gp_file_name_directory_separator(void)
76
2.79M
{   return "/";
77
2.79M
}
78
79
const char *gp_file_name_parent(void)
80
0
{   return "..";
81
0
}
82
83
const char *gp_file_name_current(void)
84
4.51M
{   return ".";
85
4.51M
}
86
87
bool gp_file_name_is_parent_allowed(void)
88
0
{   return true;
89
0
}
90
91
bool gp_file_name_is_empty_item_meanful(void)
92
10.8k
{   return false;
93
10.8k
}
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
14.3M
{
99
14.3M
    return gp_file_name_combine_generic(prefix, plen,
100
14.3M
            fname, flen, no_sibling, buffer, blen);
101
14.3M
}
102
103
bool
104
gp_file_name_good_char(unsigned char c)
105
0
{
106
0
  return c != 0 && c != '/' && c != '\\' && c != ':';
107
0
}