1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied, modified
8
or distributed except as expressly authorized under the terms of that
9
license. Refer to licensing information at http://www.artifex.com/
10
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
14
/* $Id: gp_dosfs.c 8022 2007-06-05 22:23:38Z giles $ */
15
/* Common routines for MS-DOS (any compiler) and DesqView/X, */
16
/* which has a MS-DOS-like file system. */
22
/* ------ Printer accessing ------ */
24
/* Put a printer file (which might be stdout) into binary or text mode. */
25
/* This is not a standard gp procedure, */
26
/* but all MS-DOS configurations need it. */
28
gp_set_file_binary(int prnfno, bool binary)
32
regs.h.ah = 0x44; /* ioctl */
33
regs.h.al = 0; /* get device info */
34
regs.rshort.bx = prnfno;
36
if (regs.rshort.cflag != 0 || !(regs.h.dl & 0x80))
37
return; /* error, or not a device */
39
regs.h.dl |= 0x20; /* binary (no ^Z intervention) */
41
regs.h.dl &= ~0x20; /* text */
43
regs.h.ah = 0x44; /* ioctl */
44
regs.h.al = 1; /* set device info */
48
/* ------ File accessing ------ */
50
/* Set a file into binary or text mode. */
52
gp_setmode_binary(FILE * pfile, bool binary)
54
gp_set_file_binary(fileno(pfile), binary);
55
return 0; /* Fake out dos return status */
58
/* ------ File names ------ */
60
/* Define the character used for separating file names in a list. */
61
const char gp_file_name_list_separator = ';';
63
/* Define the string to be concatenated with the file mode */
64
/* for opening files without end-of-line conversion. */
65
const char gp_fmode_binary_suffix[] = "b";
67
/* Define the file modes for binary reading or writing. */
68
const char gp_fmode_rb[] = "rb";
69
const char gp_fmode_wb[] = "wb";
71
/* -------------- Helpers for gp_file_name_combine_generic ------------- */
73
uint gp_file_name_root(const char *fname, uint len)
78
if (len > 1 && fname[0] == '\\' && fname[1] == '\\') {
79
/* A network path: "\\server\share\" */
82
for (i = 2; i < len; i++)
83
if (fname[i] == '\\' || fname[i] == '/')
88
} else if (fname[0] == '/' || fname[0] == '\\') {
89
/* Absolute with no drive. */
91
} else if (len > 1 && fname[1] == ':') {
92
/* Absolute with a drive. */
93
i = (len > 2 && (fname[2] == '/' || fname[2] == '\\') ? 3 : 2);
98
uint gs_file_name_check_separator(const char *fname, int len, const char *item)
100
if (fname[0] == '/' || fname[0] == '\\')
102
} else if (len < 0) {
103
if (fname[-1] == '/' || fname[-1] == '\\')
109
bool gp_file_name_is_parent(const char *fname, uint len)
110
{ return len == 2 && fname[0] == '.' && fname[1] == '.';
113
bool gp_file_name_is_current(const char *fname, uint len)
114
{ return len == 1 && fname[0] == '.';
117
const char *gp_file_name_separator(void)
121
const char *gp_file_name_directory_separator(void)
125
const char *gp_file_name_parent(void)
129
const char *gp_file_name_current(void)
133
bool gp_file_name_is_partent_allowed(void)
137
bool gp_file_name_is_empty_item_meanful(void)
141
gp_file_name_combine_result
142
gp_file_name_combine(const char *prefix, uint plen, const char *fname, uint flen,
143
bool no_sibling, char *buffer, uint *blen)
145
return gp_file_name_combine_generic(prefix, plen,
146
fname, flen, no_sibling, buffer, blen);