Changeset 186

Show
Ignore:
Timestamp:
06/14/07 10:35:07 (1 year ago)
Author:
ajps
Message:

Fixed up directory scanning on UNIXy platforms.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/z-file.c

    r184 r186  
    10011001{ 
    10021002        DIR *d; 
     1003        const char *dirname; 
    10031004}; 
    10041005 
     
    10061007ang_dir *my_dopen(const char *dirname) 
    10071008{ 
    1008       ang_dir *dir; 
     1009      ang_dir *dir; 
    10091010        DIR *d; 
    10101011 
     
    10191020        /* Set up the handle */ 
    10201021        dir->d = d; 
     1022        dir->dirname = string_make(dirname); 
     1023 
     1024        if (!dir->dirname) 
     1025        { 
     1026                rnfree(dir); 
     1027                return NULL; 
     1028        } 
    10211029 
    10221030        /* Success */ 
     
    10291037        struct dirent *entry; 
    10301038        struct stat filedata; 
     1039        char path[1024] = ""; 
    10311040 
    10321041        assert(dir != NULL); 
     
    10381047                if (!entry) return FALSE; 
    10391048 
     1049                path_build(path, sizeof path, dir->dirname, entry->d_name); 
     1050             
    10401051                /* Check to see if it exists */ 
    1041                 if (stat(entry->d_name, &filedata) != 0) 
     1052                if (stat(path, &filedata) != 0) 
    10421053                        continue; 
    10431054 
     
    10601071        /* Close directory */ 
    10611072        if (dir->d) 
     1073        { 
    10621074                closedir(dir->d); 
     1075                string_free(dir->dirname); 
     1076        } 
    10631077 
    10641078        /* Free memory */