ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/runParallel/getfile.c
(Generate patch)

Comparing trunk/runParallel/getfile.c (file contents):
Revision 2932 by chuckv, Thu Jul 13 15:37:28 2006 UTC vs.
Revision 2933 by chuckv, Fri Jul 14 20:39:56 2006 UTC

# Line 1 | Line 1
1 #ifdef __sun__
1  
2   #include <stdio.h>
3   #include <string.h>
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <sys/dir.h>
8 #include <sys/param.h>
9 #include <sys/stat.h>
10
11 struct direct   **namelist;
12 char* mydir;
13
14
15 int alphasort(struct direct **d1, struct direct **d2);
16
17 int amber_rst(const struct direct * dir);
18
19 int nfiles(dirname)
20     char* dirname[MAXPATHLEN + 1];
21 {
22  int nfiles;
23  mydir =  (char*)dirname;
24  nfiles = scandir((char*)dirname, &namelist, pot_only, alphasort);
25  return(nfiles);
26 }
27
28 void getfilename(int* which, char* fname, int flen) {
29  char* filename;
30  int i;
31
32  filename = namelist[*which - 1]->d_name;
33
34  for (i = 0; i < strlen(filename); i++) {
35    fname[i] = filename[i];
36  }
37  for (i = strlen(filename); i < flen; i++) {
38    fname[i] = 0;
39  }
40  flen = strlen(filename);
41 }
42
43 int
44 amber_rst(const struct direct * dir)
45 {
46
47  struct stat     buf;
48  char            filename[MAXPATHLEN + 1];
49  char            *base, *exten;
50  char            *dot = ".";
51
52  sprintf(filename, "%s/%s", mydir, dir->d_name);
53  
54  if (stat(filename, &buf) != 0)
55    {
56      return (0);
57    }
58  
59  if (buf.st_mode & S_IFDIR)  
60    {
61      return (0);
62    }
63  
64  sprintf(filename, "%s", dir->d_name);
65  base = (char*)strtok(filename, ".");
66  exten=strtok(NULL,"\0");
67
68  if (strcasecmp(exten, "pot"))
69    {
70      return (0);
71    }  
72  return (1);
73
74 }
75
76 #endif /* __sun__ */
77
78 #ifdef __linux__
79
80 #include <stdio.h>
81 #include <string.h>
4   #include <dirent.h>
5   #include <sys/param.h>
6   #include <sys/stat.h>
7 + #include "getfile.h"
8  
9   struct dirent   **namelist;
10   char* mydir;
11 + int mynode;
12 + //int nfiles(char* dirname[MAXPATHLEN + 1]);
13  
14  
15  
16  
17 < int pot_only(const struct dirent * dir);
93 <
94 < int nfiles(dirname)
95 <     char* dirname[MAXPATHLEN + 1];
17 > int nfiles(char* dirname[MAXPATHLEN + 1],int extension)
18   {
19    int nfiles;
20    mydir =  (char*)dirname;
21 <  nfiles = scandir((char*)dirname, &namelist, pot_only, alphasort);
21 >  mynode = extension;
22 >  nfiles = scandir((char*)dirname, &namelist, amber_rst, alphasort);
23    return(nfiles);
24   }
25  
26 < void getfilename_(int* which, char* fname, int flen) {
26 > void getfilename(int which, char* fname) {
27    char* filename;
28    int i;
29  
30 <  filename = namelist[*which - 1]->d_name;
31 <
30 >  filename = namelist[which]->d_name;
31 > /*
32    for (i = 0; i < strlen(filename); i++) {
33      fname[i] = filename[i];
34    }
35    for (i = strlen(filename); i < flen; i++) {
36      fname[i] = 0;
37    }
38 <  flen = strlen(filename);
38 >  */
39   }
40  
41   int
# Line 123 | Line 46 | amber_rst(const struct dirent * dir)
46    char            filename[MAXPATHLEN + 1];
47    char            *base, *exten;
48    char            *dot = ".";
49 <
49 >  char            *extenpattern;
50 >  
51    sprintf(filename, "%s/%s", mydir, dir->d_name);
52    
53    if (stat(filename, &buf) != 0)
# Line 139 | Line 63 | amber_rst(const struct dirent * dir)
63    sprintf(filename, "%s", dir->d_name);
64    base = (char*)strtok(filename, ".");
65    exten=strtok(NULL,"\0");
66 +  sprintf(extenpattern,"%i",mynode);
67  
68 <  if (strcasecmp(exten, "pot"))
68 >  if (strcasecmp(exten, extenpattern))
69      {
70        return (0);
71      }  
# Line 148 | Line 73 | amber_rst(const struct dirent * dir)
73  
74   }
75  
151 #endif /*__Linux__*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines