summaryrefslogtreecommitdiff
path: root/src/base/director.c
diff options
context:
space:
mode:
authorTomas Chvatal (scarabeus) <tomas.chvatal@gmail.com>2008-10-22 22:51:24 +0200
committerTomas Chvatal (scarabeus) <tomas.chvatal@gmail.com>2008-10-22 22:51:24 +0200
commit44daf03024fbf7cbffa10349044786f6ab784821 (patch)
treefe311eb22e2d853dfc18fde1a9e55d21815f4f82 /src/base/director.c
parente12753d2ec9db83ec08bb9db63902a82fb245cdd (diff)
Revert "X"
This reverts commit e12753d2ec9db83ec08bb9db63902a82fb245cdd.
Diffstat (limited to 'src/base/director.c')
-rwxr-xr-xsrc/base/director.c74
1 files changed, 36 insertions, 38 deletions
diff --git a/src/base/director.c b/src/base/director.c
index 4a3492b..a4c8496 100755
--- a/src/base/director.c
+++ b/src/base/director.c
@@ -12,52 +12,50 @@
typedef struct director_struct
{
- char *path;
- list_t *list;
+ char *path;
+ list_t *list;
} director_t;
-director_t *
-loadDirector(char *s)
+director_t* loadDirector(char *s)
{
- director_t *new;
- 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();
+ director_t *new;
+ 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] == '/')
+ if( s[0] == '/' )
#else
- if (s[1] == ':')
+ if( s[1] == ':' )
#endif
- strcpy(path, s);
- 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) {
- free(new->path);
- free(new);
- return NULL;
- }
+ strcpy(path, s);
+ 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 ) {
+ free(new->path);
+ free(new);
+ return NULL;
+ }
- while ((item = readdir(dir)) != NULL)
- addList(new->list, strdup(item->d_name));
- closedir(dir);
- return new;
+ while((item = readdir(dir)) != NULL)
+ addList(new->list, strdup(item->d_name) );
+ closedir(dir);
+ return new;
}
-void
-destroyDirector(director_t * p)
+void destroyDirector(director_t *p)
{
- assert(p != NULL);
- destroyListItem(p->list, free);
- free(p->path);
- free(p);
+ assert( p != NULL );
+ destroyListItem(p->list, free);
+ free(p->path);
+ free(p);
}