static void save_rec_file(char *cpf, char *buffer, int len, const struct rnetclient_args *args)
{
int fd;
- char cwd[PATH_MAX];
char *path, *fname, *tmp;
size_t fname_len;
ssize_t r;
- /* If the user provided the output directory where she wishes
- to save the receipt, then we use it. Otherwise, we save
- the file in the current working directory (CWD). */
- if (args->output_dir == NULL)
- path = getcwd(cwd, PATH_MAX);
- else {
- struct stat st;
- if (stat(args->output_dir, &st) < 0) {
- fprintf(stderr, "Could not stat directory \"%s\": %s\n", args->output_dir, strerror(errno));
- return;
- }
- if (!S_ISDIR(st.st_mode)) {
- fprintf(stderr, "Error: \"%s\" is a not a directory.\n", args->output_dir);
- return;
- }
- path = args->output_dir;
- }
+
+ path = args->output_dir;
+
/* Now it's time to decide which filename to write. We use
the declaration's filename as a base layout, because the
proprietary version of the IRPF program only recognizes
int finish = 0;
char *cpf;
error_t err;
+ char cwd[PATH_MAX];
/* Parsing the command line arguments. The argp_parse
function calls exit() if there is some error during the
if (err != 0)
fprintf(stderr, "internal error while parsing command line arguments.");
+ /* If the user provided the output directory where she wishes
+ to save the receipt, then we use it. Otherwise, we save
+ the file in the current working directory (CWD). */
+ if (rnet_args.output_dir == NULL) {
+ rnet_args.output_dir = getcwd(cwd, PATH_MAX);
+ } else {
+ struct stat st;
+ if (stat(rnet_args.output_dir, &st) < 0) {
+ fprintf(stderr, "Could not stat directory \"%s\": %s\n",
+ rnet_args.output_dir, strerror(errno));
+ exit(1);
+ }
+ if (!S_ISDIR(st.st_mode)) {
+ fprintf(stderr, "Error: \"%s\" is a not a directory.\n",
+ rnet_args.output_dir);
+ exit(1);
+ }
+ }
+
decfile = rnet_decfile_open(rnet_args.input_file);
if (!decfile) {
fprintf(stderr, "could not parse file \"%s\": %s\n", rnet_args.input_file, strerror(errno));