Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,173 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,488 people online right now. Registration is fast and FREE... Join Now!




Help using stat

 
Reply to this topicStart new topic

Help using stat, making my own ls

Barassa
post 7 Oct, 2008 - 02:02 PM
Post #1


New D.I.C Head

*
Joined: 7 Oct, 2008
Posts: 2

Well i'm very tired of looking at this , I want to show some file stats , but is not working right , can someone tell me why? sad.gif forget the last 2 lines plz.

CODE
DIR *directorio;
    struct dirent *dir_entry;
    struct stat status;

      directorio = opendir (meuArgv[1]);
      
    if (directorio != NULL)
        {
              while ((dir_entry = readdir(directorio))!=NULL)
              {     
             stat(dir_entry->d_name, &status);
            printf("%-30s %9i bytes [%c %03o] - %9d\n", dir_entry->d_name, status.st_size, dir_entry->d_type,status.st_mode,dir_entry->d_ino );
              }
        }
    closedir(directorio);
  //else
    //perror(meuArgv[1]);    



User is offlineProfile CardPM

Go to the top of the page

gabehabe
post 7 Oct, 2008 - 02:14 PM
Post #2


Working Girl.

Group Icon
Joined: 6 Feb, 2008
Posts: 5,402



Thanked 94 times

Dream Kudos: 2625

Expert In: Dingleberries

My Contributions


Just looking quickly, I can see this:
dir_entry->d_type;
The DIR object doesn't contain a definition for anything called d_type, as far as I'm aware.

These directory tutorials might point you in the right direction:
PART I
PART II

Hope this helps smile.gif

EDIT:
If that doesn't help, could you elaborate on your problem a little? Thanks. smile.gif
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/21/08 03:27PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month