/*
- * $Id: directory.c,v 1.71.2.4.2.15.2.1 2004-10-20 21:43:33 didg Exp $
+ * $Id: directory.c,v 1.71.2.4.2.15.2.2 2004-12-07 02:58:10 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
u_int16_t len16;
int size = 0;
char sep;
+ int toUTF8 = 0;
data = *cpath;
afp_errno = AFPERR_NOOBJ;
len = (unsigned char) *data++;
size = 2;
sep = 0;
+ if (afp_version >= 30) {
+ ret.m_type = 3;
+ toUTF8 = 1;
+ }
break;
case 3:
if (afp_version >= 30) {
if ( p != path ) { /* we got something */
ret.u_name = NULL;
if (afp_version >= 30) {
- /* check for OS X mangled filename :( */
char *t;
cnid_t fileid;
+
+ if (toUTF8) {
+ static char temp[ MAXPATHLEN + 1];
+
+ /* not an UTF8 name */
+ if (mtoUTF8(vol, path, strlen(path), temp, MAXPATHLEN) == -1) {
+ afp_errno = AFPERR_PARAM;
+ return( NULL );
+ }
+ strcpy(path, temp);
+ }
+ /* check for OS X mangled filename :( */
t = demangle_osx(vol, path, dir->d_did, &fileid);
if (t != path) {
/*
- * $Id: file.c,v 1.92.2.2.2.31.2.3 2004-10-30 21:43:46 didg Exp $
+ * $Id: file.c,v 1.92.2.2.2.31.2.4 2004-12-07 02:58:09 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
return( AFP_OK );
}
-int copy_path_name(char *newname, char *ibuf)
+/* ----------------
+ convert a Mac long name to an utf8 name,
+*/
+size_t mtoUTF8(const struct vol *vol, const char *src, size_t srclen, char *dest, size_t destlen)
+{
+size_t outlen;
+
+ if ((size_t)-1 == (outlen = convert_string ( vol->v_maccharset, CH_UTF8_MAC, src, srclen, dest, destlen)) ) {
+ return -1;
+ }
+ return outlen;
+}
+
+/* ---------------- */
+int copy_path_name(const struct vol *vol, char *newname, char *ibuf)
{
char type = *ibuf;
size_t plen = 0;
switch (type) {
case 2:
if (( plen = (unsigned char)*ibuf++ ) != 0 ) {
- strncpy( newname, ibuf, plen );
- newname[ plen ] = '\0';
+ if (afp_version >= 30) {
+ /* convert it to UTF8
+ */
+ if ((plen = mtoUTF8(vol, ibuf, plen, newname, AFPOBJ_TMPSIZ)) == -1)
+ return -1;
+ }
+ else {
+ strncpy( newname, ibuf, plen );
+ newname[ plen ] = '\0';
+ }
if (strlen(newname) != plen) {
/* there's \0 in newname, e.g. it's a pathname not
* only a filename.
}
/* one of the handful of places that knows about the path type */
- if (copy_path_name(newname, ibuf) < 0) {
+ if (copy_path_name(d_vol, newname, ibuf) < 0) {
return( AFPERR_PARAM );
}
/* newname is always only a filename so curdir *is* its
/*
- * $Id: file.h,v 1.16.2.2.2.3 2004-03-11 02:02:01 didg Exp $
+ * $Id: file.h,v 1.16.2.2.2.3.2.1 2004-12-07 02:58:09 didg Exp $
*
* Copyright (c) 1990,1991 Regents of The University of Michigan.
* All Rights Reserved.
extern int deletefile __P((const struct vol *, char *, int));
extern void *get_finderinfo __P((const char *, struct adouble *, void *));
-extern int copy_path_name __P((char *, char *i));
+
+extern size_t mtoUTF8 __P((const struct vol *, const char *, size_t , char *, size_t ));
+extern int copy_path_name __P((const struct vol *, char *, char *i));
extern u_int32_t get_id __P((struct vol *, struct adouble *, const struct stat *,
const cnid_t , const char *, const int ));
/*
- * $Id: filedir.c,v 1.45.2.2.2.14 2004-10-06 20:05:14 bfernhomberg Exp $
+ * $Id: filedir.c,v 1.45.2.2.2.14.2.1 2004-12-07 02:58:08 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
}
/* another place where we know about the path type */
- if ((plen = copy_path_name(newname, ibuf)) < 0) {
+ if ((plen = copy_path_name(vol, newname, ibuf)) < 0) {
return( AFPERR_PARAM );
}
}
/* one more place where we know about path type */
- if ((plen = copy_path_name(newname, ibuf)) < 0) {
+ if ((plen = copy_path_name(vol, newname, ibuf)) < 0) {
return( AFPERR_PARAM );
}