Back to index

wims  3.65+svn20090927
Functions
dir.c File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int remove_tree (char *dirname)
void mkdirs (char *s)

Function Documentation

void mkdirs ( char *  s)

Definition at line 47 of file dir.c.

{
    struct stat st;
    if(stat(s,&st)==-1) {
       if(strrchr(s,'/')!=NULL) {
           char buf[MAX_FNAME+1];
           mystrncpy(buf,s,sizeof(buf));
           *strrchr(buf,'/')=0; mkdirs(buf);
       }
       mkdir(s,S_IRWXU|S_IRWXG|S_IRWXO);
    }
}

Here is the caller graph for this function:

int remove_tree ( char *  dirname)

Definition at line 21 of file dir.c.

{
    DIR *sdir;
    struct dirent *f;
    struct stat dst;

    sdir=opendir(dirname);
    if(sdir==NULL) {   /* Cannot open session directory. */
       return -1;
    }
    while((f=readdir(sdir))!=NULL) {
       char fname[MAX_LINELEN+1];
       if(strcmp(".",f->d_name)==0 || strcmp("..",f->d_name)==0) continue;
       snprintf(fname,sizeof(fname),"%s/%s",dirname,f->d_name);
       if(lstat(fname,&dst)) continue;
       if(S_ISDIR(dst.st_mode)) remove_tree(fname);
       else remove(fname);
    }
    closedir(sdir);
    if(rmdir(dirname)<0) {  /* Cannot remove directory. */
       return -1;
    }
    return 0;
}

Here is the caller graph for this function: