{
struct stat buffer;
- if (stat(fname, &buffer) == 0)
+ if(stat(fname, &buffer) == 0)
return 0;
else
return 1;
char i = 0;
humanread = splitgroesse;
- while (humanread >= 1024) {
+ while(humanread >= 1024) {
i++;
humanread /= 1024;
- switch (i) {
+ switch(i) {
case 1:
einheit = 'K';
break;
}
}
- printf("Restlicher Platz in Bytes(%s): %lld (%lld %c)\n",
- output, splitgroesse, humanread, einheit);
+ printf("Restlicher Platz in Bytes(%s): %lld (%lld %c)\n", output,
+ splitgroesse, humanread, einheit);
}
void splitter(const char *input, char *output, const char *rest,
unsigned long long filesize;
struct stat st;
- while (fscanf(in, "%[^\n]\n", pfad) == 1) {
+ while(fscanf(in, "%[^\n]\n", pfad) == 1) {
stat(pfad, &st);
// filesize inklusive overhead
filesize = 33 + strlen(pfad) + st.st_size;
- if (splitgroesse >= filesize) {
+ if(splitgroesse >= filesize) {
splitgroesse -= filesize;
fprintf(out, "%s\n", pfad);
} else {
- if (exists(rest) == 1)
+ if(exists(rest) == 1)
re = fopen(rest, "w");
fprintf(re, "%s\n", pfad);
fclose(in);
fclose(out);
- if (exists(rest) == 0)
+ if(exists(rest) == 0)
fclose(re);
printHumanReadSize(output, splitgroesse);
int cmpfunc(const void *filea, const void *fileb)
{
- long long unsigned int a = ((const struct file_size*) filea)->fsize;
- long long unsigned int b = ((const struct file_size*) fileb)->fsize;
+ long long unsigned int a = ((const struct file_size*)filea)->fsize;
+ long long unsigned int b = ((const struct file_size*)fileb)->fsize;
- if (a < b)
+ if(a < b)
return 1;
- else if (a > b)
+ else if(a > b)
return -1;
- else if (a == b)
+ else if(a == b)
return 0;
else
return -2;
out = fopen(output, "w");
// input-Datei Zeilenanzahl
- while (fscanf(in, "%[^\n]\n", pfad) == 1) {
+ while(fscanf(in, "%[^\n]\n", pfad) == 1) {
lines++;
}
fseek(in, 0L, SEEK_SET);
// struct Array with Dateienanzahl
struct file_size *fs = NULL;
- fs = (struct file_size *) malloc((lines -1) * sizeof(struct file_size));
+ fs = (struct file_size *)malloc((lines - 1) * sizeof(struct file_size));
lines = 0;
- while (fscanf(in, "%[^\n]\n", pfad) == 1) {
+ while(fscanf(in, "%[^\n]\n", pfad) == 1) {
// Lese Dateieigenschaften in st struct
stat(pfad, &st);
- if (st.st_size <= split) {
+ if(st.st_size <= split) {
// kopiert den pfad String ins struct
strcpy(fs[lines].name, pfad);
// Filesize in struct
lines++;
} else {
// irgnore List erstellen
- if (exists("ignore") == 1)
+ if(exists("ignore") == 1)
ignore = fopen("ignore", "w");
fprintf(ignore, "%s\n", pfad);
}
}
- fs = (struct file_size *)
- realloc(fs, (lines+1) * sizeof(struct file_size));
+ fs = (struct file_size *)realloc(fs,
+ (lines + 1) * sizeof(struct file_size));
// sortiere das array fs mit stucts
qsort(fs, lines, sizeof(struct file_size), cmpfunc);
// schreibe in out die sortieren liste
- for (int i = 0; i < lines; i++) {
+ for(int i = 0; i < lines; i++) {
fprintf(out, "%s\n", fs[i].name);
}
// schliesse alle Textdateien
fclose(in);
fclose(out);
- if (exists("ignore") == 0)
+ if(exists("ignore") == 0)
fclose(ignore);
}
unsigned long long split = dvd5;
// gib die Funktionsübersicht aus bei zu wenig Parameter
- if (argc <= 3) {
+ if(argc <= 3) {
usage();
return 1;
}
// Lese Parameter ein
int c;
- while ((c = getopt(argc, argv, ":59bdcf:")) != -1) {
+ while((c = getopt(argc, argv, ":59bdcf:")) != -1) {
switch(c) {
case '5':
split = dvd5;
char outname[sizeof output] = "";
int num = 1;
- while (exists(rest) == 0) {
- sprintf(outname, "%s%03d", output , num++);
- if (exists(rest) == 0) {
+ while(exists(rest) == 0) {
+ sprintf(outname, "%s%03d", output, num++);
+ if(exists(rest) == 0) {
filecopy(rest, work);
remove(rest);
}