diff options
author | Kjetil Ørbekk <orbekk@pvv.ntnu.no> | 2008-08-13 14:20:36 +0200 |
---|---|---|
committer | Kjetil Ørbekk <orbekk@pvv.ntnu.no> | 2008-08-13 14:20:36 +0200 |
commit | baaa0b53ec7a6d31878e18ecca6083d0c86c848c (patch) | |
tree | 7b3454255de789c5def247bc87e36c11875b0837 /readdir_test.c | |
parent | d2727a60c0b2d6967d9cce3ca2696e1cab79e322 (diff) |
- Removed old test files
Diffstat (limited to 'readdir_test.c')
-rw-r--r-- | readdir_test.c | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/readdir_test.c b/readdir_test.c deleted file mode 100644 index 0cca325..0000000 --- a/readdir_test.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -#include <stdio.h> -#include <sys/types.h> -#include <dirent.h> -#include <string.h> -#include <errno.h> - -extern int errno; - -void print_directory (char *path, int level) -{ - DIR *dir = opendir (path); - int i; - - if (dir == NULL) { - for (i=0; i<level; i++) printf (" "); - if (errno == EACCES) - printf ("* No access\n"); - return; - } - - struct dirent *de; - - while ((de = readdir (dir)) != NULL) { - if (strcmp (de->d_name, "." ) == 0 || - strcmp (de->d_name, "..") == 0) - continue; - - for (i=0; i<level; i++) printf (" "); - printf ("- %s\n", de->d_name); - - if (de->d_type == 4) { /* ToDo: have to use lstat or something */ - char subdir[strlen(path) + strlen(de->d_name) + 1]; - strcpy (subdir, path); - strcpy (subdir+strlen(path), "/"); - strcpy (subdir+strlen(path)+1, de->d_name); - - print_directory (subdir, level+1); - } - } -} - -int main (int argc, char **argv) -{ - if (argc != 2) - return -1; - - print_directory (argv[1], 0); - return 0; -} - |