Compare commits
No commits in common. "main" and "96f9ded185bc6d4455c1514365c31f08f87ecb51" have entirely different histories.
main
...
96f9ded185
2 changed files with 49 additions and 66 deletions
|
@ -1,6 +0,0 @@
|
|||
# multif
|
||||
|
||||
a multiplexer for distributing lines over a
|
||||
directory of files
|
||||
|
||||
|
31
multif.c
31
multif.c
|
@ -8,6 +8,11 @@
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 2)
|
||||
{
|
||||
fprintf(stderr, "Error : You must specify a directory\n");
|
||||
return 1;
|
||||
}
|
||||
DIR* FD;
|
||||
struct dirent* in_file;
|
||||
FILE *entry_file;
|
||||
|
@ -15,22 +20,13 @@ int main(int argc, char *argv[])
|
|||
char *line = NULL;
|
||||
size_t len = 0;
|
||||
ssize_t lineSize = 0;
|
||||
int burst = 1;
|
||||
if (argc < 2)
|
||||
{
|
||||
fprintf(stderr, "Error : You must specify a directory\n");
|
||||
return 1;
|
||||
}
|
||||
if (argc >= 3)
|
||||
burst = atoi(argv[2]);
|
||||
if (burst <= 0)
|
||||
{
|
||||
fprintf(stderr, "Error : burst must be an integer greater than 0\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *directory = argv[1];
|
||||
strcat(directory, "/");
|
||||
|
||||
//lineSize = getline(&line, &len, stdin);
|
||||
while (lineSize != -1)
|
||||
{
|
||||
/* Scanning the in directory */
|
||||
if (NULL == (FD = opendir (argv[1])))
|
||||
{
|
||||
|
@ -38,12 +34,10 @@ int main(int argc, char *argv[])
|
|||
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (lineSize != -1)
|
||||
{
|
||||
while ((in_file = readdir(FD)))
|
||||
{
|
||||
|
||||
char *line = NULL;
|
||||
if (!strcmp (in_file->d_name, ".") || !strcmp (in_file->d_name, ".."))
|
||||
continue;
|
||||
|
||||
|
@ -51,9 +45,6 @@ int main(int argc, char *argv[])
|
|||
strcpy(entry_path,directory);
|
||||
strcat(entry_path,in_file->d_name);
|
||||
|
||||
int c;
|
||||
for (c = 0; c < burst; c++) {
|
||||
char *line = NULL;
|
||||
entry_file = fopen(entry_path, "a");
|
||||
if (entry_file == NULL)
|
||||
{
|
||||
|
@ -73,7 +64,5 @@ int main(int argc, char *argv[])
|
|||
free(line);
|
||||
}
|
||||
}
|
||||
rewinddir(FD);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue