diff options
| author | scarab <scarab@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-08-15 19:57:10 +0000 |
|---|---|---|
| committer | scarab <scarab@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-08-15 19:57:10 +0000 |
| commit | 7bbd60007620cf3cc3ee7a913f7010588808ebb2 (patch) | |
| tree | 34e72f66dfd1076e23c43074786f935aca70cba1 /src/base/director.c | |
| parent | 50ba3d5e1e9f9eeda049a348efa4645af07610bc (diff) | |
"- initial commit for GETTEXT support and K&R compilance"
git-svn-id: http://opensvn.csie.org/tuxanci_ng@196 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/base/director.c')
| -rwxr-xr-x | src/base/director.c | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/src/base/director.c b/src/base/director.c index 68bfae5..a4c8496 100755 --- a/src/base/director.c +++ b/src/base/director.c @@ -22,55 +22,40 @@ director_t* loadDirector(char *s) DIR *dir; struct dirent *item; char path[STR_PATH_SIZE]; - assert( s != 0 ); - new = malloc( sizeof(director_t) ); memset(new, 0, sizeof(director_t) ); - new->list = newList(); #ifndef __WIN32__ if( s[0] == '/' ) #else if( s[1] == ':' ) #endif - { strcpy(path, s); - } - else - { - // tohle je opravdu dobre... + else { + // this is really correct aproach getcwd(path, STR_PATH_SIZE); strcat(path, "/"); strcat(path, s); } new->path = strdup(path); - dir = opendir(new->path); - - if( dir == NULL ) - { + if( dir == NULL ) { free(new->path); free(new); - return NULL; } - while( ( item = readdir(dir) ) != NULL ) + while((item = readdir(dir)) != NULL) addList(new->list, strdup(item->d_name) ); - closedir(dir); - return new; } void destroyDirector(director_t *p) { assert( p != NULL ); - destroyListItem(p->list, free); free(p->path); free(p); } - - |