4 * Copyright (C) 1995-1997 Paul H. Hargrove
5 * This file may be distributed under the terms of the GNU General Public License.
7 * This file contains routines for converting between the Macintosh
8 * character set and various other encodings. This includes dealing
9 * with ':' vs. '/' as the path-element separator.
14 /*================ Global functions ================*/
19 * Given a 'Pascal String' (a string preceded by a length byte) in
20 * the Macintosh character set produce the corresponding filename using
21 * the 'trivial' name-mangling scheme, returning the length of the
22 * mangled filename. Note that the output string is not NULL
25 * The name-mangling works as follows:
26 * The character '/', which is illegal in Linux filenames is replaced
27 * by ':' which never appears in HFS filenames. All other characters
28 * are passed unchanged from input to output.
30 int hfs_mac2triv(char *out
, const struct hfs_name
*in
)
38 for (i
= 0; i
< len
; i
++) {
40 *out
++ = c
== '/' ? ':' : c
;
48 * Given an ASCII string (not null-terminated) and its length,
49 * generate the corresponding filename in the Macintosh character set
50 * using the 'trivial' name-mangling scheme, returning the length of
51 * the mangled filename. Note that the output string is not NULL
54 * This routine is a inverse to hfs_mac2triv().
55 * A ':' is replaced by a '/'.
57 void hfs_triv2mac(struct hfs_name
*out
, struct qstr
*in
)
63 out
->len
= len
= min((unsigned int)HFS_NAMELEN
, in
->len
);
66 for (i
= 0; i
< len
; i
++) {
68 *dst
++ = c
== ':' ? '/' : c
;
70 for (; i
< HFS_NAMELEN
; i
++)