Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> How to get each file name from a Unix dir in filename (not I-node) order.

How to get each file name from a Unix dir in filename (not I-node) order.

From: Alister Miller <Alister_miller_at_nospamdse.vic.gov.au>
Date: 1998/09/18
Message-ID: <3601B7F9.C873B6AB@nospamdse.vic.gov.au>#1/1

I have a program (Pro*C) that loops through each file in a directory, but I want it get each file in filename order.

I find that the program below does it in i-node order (due to the way "readdir" works), which is usually but not always the same as filename order.

Can anyone help me?



main
{
  char *sDirName[100];
  DIR *dp;
  struct dirent *direntp;
  char *sFileName[257];

  strcpy(sDirName, "/u04/users/fe/CASES_load");

  if ((dp = opendir(sDirName)) == NULL)
  { exit(EXIT_FAILURE); }

  while ((direntp = readdir(dp)) != NULL)   {
    /* Get file name */
    sprintf((char *) sFileName, "%s", direntp->d_name);   }

  closedir(dp);
}


Alister Miller

(E-mail preferred. Remove "nospam" for return e-mail) Received on Fri Sep 18 1998 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US