[runtime] When shadow-copying assemblies, use the io portability function to find...
authorMarek Habersack <grendel@twistedcode.net>
Wed, 18 May 2011 19:54:56 +0000 (21:54 +0200)
committerMarek Habersack <grendel@twistedcode.net>
Wed, 18 May 2011 20:03:44 +0000 (22:03 +0200)
This is necessary in situations when managed code pases case-insenstive file name and the
file on disk uses different case. stat(2) would return an error in such situation and, in effect,
the stat structure would get invalid/random values in its fields.

mono/metadata/appdomain.c

index b8b00af4c2951e430e907faa564fbb299cb7b622..0654fa6f2bc0809021fa5d129a02ef8e538a714f 100644 (file)
@@ -1481,10 +1481,22 @@ static gboolean
 private_file_needs_copying (const char *src, struct stat *sbuf_src, char *dest)
 {
        struct stat sbuf_dest;
+       gchar *real_src = mono_portability_find_file (src, TRUE);
+
+       if (!real_src)
+               real_src = (gchar*)src;
        
-       if (stat (src, sbuf_src) == -1 || stat (dest, &sbuf_dest) == -1)
+       if (stat (real_src, sbuf_src) == -1) {
+               time_t tnow = time (NULL);
+               memset (sbuf_src, 0, sizeof (*sbuf_src));
+               sbuf_src->st_mtime = tnow;
+               sbuf_src->st_atime = tnow;
                return TRUE;
+       }
 
+       if (stat (dest, &sbuf_dest) == -1)
+               return TRUE;
+       
        if (sbuf_src->st_size == sbuf_dest.st_size &&
            sbuf_src->st_mtime == sbuf_dest.st_mtime)
                return FALSE;