fix indention

no more mixing tabs and spaces lol
This commit is contained in:
xfnw 2022-01-03 13:24:37 -05:00
parent 8c09af80fb
commit 9e6e2457e2

118
multif.c
View file

@ -8,72 +8,72 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
DIR* FD; DIR* FD;
struct dirent* in_file; struct dirent* in_file;
FILE *entry_file; FILE *entry_file;
char buffer[BUFSIZ]; char buffer[BUFSIZ];
char *line = NULL; char *line = NULL;
size_t len = 0; size_t len = 0;
ssize_t lineSize = 0; ssize_t lineSize = 0;
int burst = 1; int burst = 1;
if (argc < 2) if (argc < 2)
{ {
fprintf(stderr, "Error : You must specify a directory\n"); fprintf(stderr, "Error : You must specify a directory\n");
return 1; return 1;
} }
if (argc >= 3) if (argc >= 3)
burst = atoi(argv[2]); burst = atoi(argv[2]);
if (burst <= 0) if (burst <= 0)
{ {
fprintf(stderr, "Error : burst must be an integer greater than 0\n"); fprintf(stderr, "Error : burst must be an integer greater than 0\n");
return 1; return 1;
} }
char *directory = argv[1]; char *directory = argv[1];
strcat(directory, "/"); strcat(directory, "/");
/* Scanning the in directory */ /* Scanning the in directory */
if (NULL == (FD = opendir (argv[1]))) if (NULL == (FD = opendir (argv[1])))
{ {
fprintf(stderr, "Error : Failed to open input directory - %s\n", strerror(errno)); fprintf(stderr, "Error : Failed to open input directory - %s\n", strerror(errno));
return 1; return 1;
} }
while (lineSize != -1) while (lineSize != -1)
{ {
while ((in_file = readdir(FD))) while ((in_file = readdir(FD)))
{ {
if (!strcmp (in_file->d_name, ".") || !strcmp (in_file->d_name, "..")) if (!strcmp (in_file->d_name, ".") || !strcmp (in_file->d_name, ".."))
continue; continue;
char entry_path[4096]; char entry_path[4096];
strcpy(entry_path,directory); strcpy(entry_path,directory);
strcat(entry_path,in_file->d_name); strcat(entry_path,in_file->d_name);
int c; int c;
for (c = 0; c < burst; c++) { for (c = 0; c < burst; c++) {
char *line = NULL; char *line = NULL;
entry_file = fopen(entry_path, "a"); entry_file = fopen(entry_path, "a");
if (entry_file == NULL) if (entry_file == NULL)
{ {
fprintf(stderr, "Error : Failed to open entry file - %s\n", strerror(errno)); fprintf(stderr, "Error : Failed to open entry file - %s\n", strerror(errno));
return 1; return 1;
}
lineSize = getline(&line, &len, stdin);
if (lineSize == -1)
return 0;
fprintf(entry_file, line);
/* When you finish with the file, close it */
fclose(entry_file);
free(line);
} }
lineSize = getline(&line, &len, stdin);
if (lineSize == -1)
return 0;
fprintf(entry_file, line);
/* When you finish with the file, close it */
fclose(entry_file);
free(line);
} }
} rewinddir(FD);
rewinddir(FD); }
} return 0;
return 0;
} }