]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/desktop.c
Merge branch 'product-2-2' of git://github.com/franklahm/Netatalk into alex-master
[netatalk.git] / etc / afpd / desktop.c
index 8446a848b26baed169f915f280ef4f88e3b97b5d..da39e9b124e4df74be91592d3c0a81a35221e5f1 100644 (file)
 #include "mangle.h"
 
 
+typedef struct _U2MMAP {
+    char *mname;
+    char *uname;
+} U2MMAP;
+
+U2MMAP u2mmap[] = {
+    { "Network Trash Folder", ".AppleTrash" },
+    { "Temporary Items", ".AppleTemp" },
+    { "TheVolumeSettingsFolder", ".AppleVolumeSettings" },
+    { "TheFindByContentFolder", ".AppleFindByContent" },
+    { 0L, 0L } /* end of list */
+};
+
+
 int afp_opendt(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *rbuflen)
 {
     struct vol *vol;
@@ -598,6 +612,7 @@ char *mtoupath(const struct vol *vol, char *mpath, cnid_t did, int utf8)
     size_t       inplen;
     size_t       outlen;
     u_int16_t   flags;
+    U2MMAP       *u2m;
         
     if ( *mpath == '\0' ) {
         strcpy(upath, ".");
@@ -615,6 +630,14 @@ char *mtoupath(const struct vol *vol, char *mpath, cnid_t did, int utf8)
     m = mpath;
     u = upath;
 
+    u2m = u2mmap;
+    while(u2m->mname) {
+        if (strcmp(m, u2m->mname) == 0) {
+            m = u2m->uname;
+        }
+        u2m++;
+    }
+
     inplen = strlen(m);
     outlen = MAXPATHLEN;
 
@@ -638,6 +661,7 @@ char *utompath(const struct vol *vol, char *upath, cnid_t id, int utf8)
     char        *m, *u;
     u_int16_t    flags;
     size_t       outlen;
+    U2MMAP       *u2m;
 
     m = mpath;
     outlen = strlen(upath);
@@ -651,12 +675,21 @@ char *utompath(const struct vol *vol, char *upath, cnid_t id, int utf8)
         LOG(log_error, logtype_afpd, "Conversion from %s to %s for %s (%u) failed.", vol->v_volcodepage, vol->v_maccodepage, u, ntohl(id));
        goto utompath_error;
     }
+    mpath[outlen] = 0;
 
     flags = !!(flags & CONV_REQMANGLE);
 
     if (utf8)
         flags |= 2;
 
+    u2m = u2mmap;
+    while(u2m->mname) {
+        if (strcmp(mpath, u2m->uname) == 0) {
+            strcpy(mpath, u2m->mname);
+        }
+        u2m++;
+    }
+
     m = mangle(vol, mpath, outlen, upath, id, flags);
 
 #ifdef DEBUG