Main.OpendirInC History

Hide minor edits - Show changes to markup

2006-11-21,01:30 下午 by 61.229.53.62 -
Changed line 2 from:
to
2006-11-21,01:30 下午 by 61.229.53.62 -
Changed line 2 from:
to
2006-11-21,12:59 下午 by 61.229.53.62 -
Changed lines 1-2 from:
to
2006-11-21,12:58 下午 by 61.229.53.62 -
Changed lines 1-2 from:
  • Open dir using POSIX
to
2006-11-21,12:16 下午 by 61.229.53.62 -
Changed lines 1-40 from:
  • Header file: dirent.h
  • Data type for a directory stream: DIR
  • Data type for a single entries: struct dirent
  • Functions:
    • Opening a Directory Stream
      • DIR * opendir (const char *dirname)
      • int dirfd (DIR *dirstream)
    • Reading and Closing a Directory Stream
      • struct dirent * readdir (DIR *dirstream)
      • int readdir_r (DIR *dirstream, struct dirent *entry, struct dirent **result)
      • struct dirent64 * readdir64 (DIR *dirstream)
      • int readdir64_r (DIR *dirstream, struct dirent64 *entry, struct dirent64 **result)
      • int closedir (DIR *dirstream)
  • Sample code
#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>

int
main (void)
{
        DIR *dp;
        struct dirent *ep;

        dp = opendir ("./");
        if (dp != NULL)
        {
                while (ep = readdir (dp))
                puts (ep->d_name);
                (void) closedir (dp);
        }
        else
        perror ("Couldn't open the directory");

        return 0;
}
  • Ref: File System Interface in The GNU C Library
to
  • Open dir using POSIX
2006-11-21,11:59 上午 by 61.229.53.62 -
2006-11-21,11:57 上午 by 61.229.53.62 -
Changed lines 15-16 from:
to
#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>

int
main (void)
{
        DIR *dp;
        struct dirent *ep;

        dp = opendir ("./");
        if (dp != NULL)
        {
                while (ep = readdir (dp))
                puts (ep->d_name);
                (void) closedir (dp);
        }
        else
        perror ("Couldn't open the directory");

        return 0;
}
2006-11-21,11:52 上午 by 61.229.53.62 -
Changed lines 15-39 from:
#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>

int
main (void)
{
        DIR *dp;
        struct dirent *ep;

        dp = opendir ("./");
        if (dp != NULL)
        {
                while (ep = readdir (dp))
                puts (ep->d_name);
                (void) closedir (dp);
        }
        else
        perror ("Couldn't open the directory");

        return 0;
}
to
2006-11-21,11:40 上午 by 61.229.53.62 -
Changed line 3 from:
  • Data type for a single entries: struct dirent
to
  • Data type for a single entries: struct dirent
2006-11-21,11:40 上午 by 61.229.53.62 -
Added lines 1-40:
  • Header file: dirent.h
  • Data type for a directory stream: DIR
  • Data type for a single entries: struct dirent
  • Functions:
    • Opening a Directory Stream
      • DIR * opendir (const char *dirname)
      • int dirfd (DIR *dirstream)
    • Reading and Closing a Directory Stream
      • struct dirent * readdir (DIR *dirstream)
      • int readdir_r (DIR *dirstream, struct dirent *entry, struct dirent **result)
      • struct dirent64 * readdir64 (DIR *dirstream)
      • int readdir64_r (DIR *dirstream, struct dirent64 *entry, struct dirent64 **result)
      • int closedir (DIR *dirstream)
  • Sample code
#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>

int
main (void)
{
        DIR *dp;
        struct dirent *ep;

        dp = opendir ("./");
        if (dp != NULL)
        {
                while (ep = readdir (dp))
                puts (ep->d_name);
                (void) closedir (dp);
        }
        else
        perror ("Couldn't open the directory");

        return 0;
}
  • Ref: File System Interface in The GNU C Library
 

PmWiki can't process your request

Cannot acquire lockfile

We are sorry for any inconvenience.