2 |
- |
1 |
/* Copyright (C) 1994, 1996 Aladdin Enterprises. All rights reserved.
|
|
|
2 |
|
|
|
3 |
This software is provided AS-IS with no warranty, either express or
|
|
|
4 |
implied.
|
|
|
5 |
|
|
|
6 |
This software is distributed under license and may not be copied,
|
|
|
7 |
modified or distributed except as expressly authorized under the terms
|
|
|
8 |
of the license contained in the file LICENSE in this distribution.
|
|
|
9 |
|
|
|
10 |
For more information about licensing, please refer to
|
|
|
11 |
http://www.ghostscript.com/licensing/. For information on
|
|
|
12 |
commercial licensing, go to http://www.artifex.com/licensing/ or
|
|
|
13 |
contact Artifex Software, Inc., 101 Lucas Valley Road #110,
|
|
|
14 |
San Rafael, CA 94903, U.S.A., +1(415)492-9861.
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
/* $Id: gp_unifn.c,v 1.16 2004/01/05 23:34:47 giles Exp $ */
|
|
|
18 |
/* Unix-like file name syntax platform routines for Ghostscript */
|
|
|
19 |
#include "gx.h"
|
|
|
20 |
#include "gp.h"
|
|
|
21 |
#include "gpmisc.h"
|
|
|
22 |
#include "gsutil.h"
|
|
|
23 |
|
|
|
24 |
/* Define the character used for separating file names in a list. */
|
|
|
25 |
const char gp_file_name_list_separator = ':';
|
|
|
26 |
|
|
|
27 |
/* Define the string to be concatenated with the file mode */
|
|
|
28 |
/* for opening files without end-of-line conversion. */
|
|
|
29 |
const char gp_fmode_binary_suffix[] = "";
|
|
|
30 |
|
|
|
31 |
/* Define the file modes for binary reading or writing. */
|
|
|
32 |
const char gp_fmode_rb[] = "r";
|
|
|
33 |
const char gp_fmode_wb[] = "w";
|
|
|
34 |
|
|
|
35 |
/* -------------- Helpers for gp_file_name_combine_generic ------------- */
|
|
|
36 |
|
|
|
37 |
uint gp_file_name_root(const char *fname, uint len)
|
|
|
38 |
{ if (len > 0 && fname[0] == '/')
|
|
|
39 |
return 1;
|
|
|
40 |
return 0;
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
uint gs_file_name_check_separator(const char *fname, int len, const char *item)
|
|
|
44 |
{ if (len > 0) {
|
|
|
45 |
if (fname[0] == '/')
|
|
|
46 |
return 1;
|
|
|
47 |
} else if (len < 0) {
|
|
|
48 |
if (fname[-1] == '/')
|
|
|
49 |
return 1;
|
|
|
50 |
}
|
|
|
51 |
return 0;
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
bool gp_file_name_is_parent(const char *fname, uint len)
|
|
|
55 |
{ return len == 2 && fname[0] == '.' && fname[1] == '.';
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
bool gp_file_name_is_current(const char *fname, uint len)
|
|
|
59 |
{ return len == 1 && fname[0] == '.';
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
const char *gp_file_name_separator(void)
|
|
|
63 |
{ return "/";
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
const char *gp_file_name_directory_separator(void)
|
|
|
67 |
{ return "/";
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
const char *gp_file_name_parent(void)
|
|
|
71 |
{ return "..";
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
const char *gp_file_name_current(void)
|
|
|
75 |
{ return ".";
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
bool gp_file_name_is_partent_allowed(void)
|
|
|
79 |
{ return true;
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
bool gp_file_name_is_empty_item_meanful(void)
|
|
|
83 |
{ return false;
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
gp_file_name_combine_result
|
|
|
87 |
gp_file_name_combine(const char *prefix, uint plen, const char *fname, uint flen,
|
|
|
88 |
bool no_sibling, char *buffer, uint *blen)
|
|
|
89 |
{
|
|
|
90 |
return gp_file_name_combine_generic(prefix, plen,
|
|
|
91 |
fname, flen, no_sibling, buffer, blen);
|
|
|
92 |
}
|