All pastes #938658 Raw Edit

Zeug

public text v1 · immutable
·published 2008-03-11 20:08 UTC
rendered paste body
/*
 *      showdir.c
 *      
 *      Copyright 2008 Philipp <volton@volton-laptop>
 *      
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */


#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>

int main(int argc, char** argv)
{
	
	DIR *currentdir;
	struct dirent *currentdirent;
	
	currentdir = opendir (".");
	
	if (currentdir == NULL) {
		
		printf ("Error opening dir!\n");
		
	}
	
	currentdirent = readdir ( currentdir );
		
	while ( currentdir != NULL ) {
		
		printf ("%s\n", (*currentdir).d_name );
		
		currentdirent = readdir ( currentdir );
		
	}
	
	if (closedir ( currentdir ) == -1 ) {
		
		printf ("Error closing dir!\n");
	
	}
	
	
	return 0;
}