forked from adrianlopezroche/fdupes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to log file deletions to chosen file.
- Loading branch information
1 parent
ca95a01
commit 076d319
Showing
14 changed files
with
478 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <errno.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
#include "dir.h" | ||
|
||
char *getworkingdirectory() | ||
{ | ||
size_t size; | ||
char *result; | ||
char *new_result; | ||
char *cwd; | ||
|
||
size = 1024; | ||
|
||
result = 0; | ||
do | ||
{ | ||
new_result = (char*) realloc(result, size); | ||
if (new_result == 0) | ||
{ | ||
if (result != 0) | ||
free(result); | ||
|
||
return 0; | ||
} | ||
|
||
result = new_result; | ||
|
||
cwd = getcwd(result, size); | ||
|
||
size *= 2; | ||
} while (cwd == 0 && errno == ERANGE); | ||
|
||
if (cwd == 0) | ||
{ | ||
free(result); | ||
return 0; | ||
} | ||
|
||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef DIR_H | ||
#define DIR_H | ||
|
||
char *getworkingdirectory(); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <string.h> | ||
#include "fmatch.h" | ||
|
||
/* Test whether given string matches text at current file position. | ||
*/ | ||
void fmatch(FILE *file, char *matchstring, int *is_match, size_t *chars_read) | ||
{ | ||
size_t len; | ||
int x; | ||
int c; | ||
|
||
*is_match = 0; | ||
*chars_read = 0; | ||
|
||
len = strlen(matchstring); | ||
for (x = 0; x < len; ++x) | ||
{ | ||
c = fgetc(file); | ||
if (c == EOF) | ||
return; | ||
|
||
(*chars_read)++; | ||
|
||
if ((char)c != matchstring[x]) | ||
return; | ||
} | ||
|
||
*is_match = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef FMATCH_H | ||
#define FMATCH_H | ||
|
||
#include <stdio.h> | ||
|
||
void fmatch(FILE *file, char *matchstring, int *is_match, size_t *chars_read); | ||
|
||
#endif |
Oops, something went wrong.