forked from cc65/cc65
-
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.
This will allow using unlink()/remove() in sim65 programs Use it to unlink fgets' test output file
- Loading branch information
1 parent
6593768
commit 0dd7b0c
Showing
5 changed files
with
106 additions
and
5 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
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,55 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <unistd.h> | ||
|
||
int fails = 0; | ||
|
||
|
||
static void create_out_file(const char *outfile_path) { | ||
FILE *out; | ||
|
||
|
||
out = fopen(outfile_path, "wb"); | ||
if (out == NULL) { | ||
printf("Could not create %s\n", outfile_path); | ||
fails++; | ||
return; | ||
} | ||
fclose(out); | ||
} | ||
|
||
int main (int argc, char **argv) | ||
{ | ||
int r; | ||
static char outfile_path[FILENAME_MAX+1]; | ||
|
||
sprintf(outfile_path, "%s.test.out", argv[0]); | ||
|
||
create_out_file(outfile_path); | ||
r = remove(outfile_path); | ||
if (r != 0) { | ||
printf("could not remove() %s\n", outfile_path); | ||
fails++; | ||
} | ||
|
||
create_out_file(outfile_path); | ||
r = unlink(outfile_path); | ||
if (r != 0) { | ||
printf("could not unlink() %s\n", outfile_path); | ||
fails++; | ||
} | ||
|
||
r = remove("klsdfjqlsjdflkqjdsoizu"); | ||
if (r == 0) { | ||
printf("remove()ing non-existent file succeeded\n"); | ||
fails++; | ||
} | ||
|
||
r = unlink("klsdfjqlsjdflkqjdsoizu"); | ||
if (r == 0) { | ||
printf("unlink()ing non-existent file succeeded\n"); | ||
fails++; | ||
} | ||
|
||
return fails; | ||
} |