All pastes #70814 Raw Edit

Untitled

public c v1 · immutable
#70814 ·published 2006-06-24 21:21 UTC
rendered paste body
//  stat(dir->d_name, &statinfo); <-- ar tai teisingas uzrasas? #include <stdio.h>#include <dirent.h>#include <sys/stat.h>#include <sys/types.h>int die(char *msg)  {	  while (*msg != '\0')		  printf("%c", *msg++);	  exit(1);  }int main()  {	 DIR *dp;	 struct dirent *dir;     struct stat statinfo;	 if ((dp = opendir(".")) == NULL) die("Cannot Open Dir, exiting!");     while ((dir = readdir(dp)) != NULL )		 	 {		 if (dir->d_ino != 0) {	     if(stat(dir->d_name,&statinfo) == -1)		          {			perror("stat");			exit(1);		        }			 printf("%s", dir->d_name);	  		 stat(dir->d_name, &statinfo);	     	 if (statinfo.st_mode & S_IFMT == S_IFDIR)		    	 printf(" -- katalogas"); else printf(" ... failas");				 }		 			                                    	 }      return 0 ;  }