Fixed file output directory.

- This fix is very minimal, as a result output directory arguments
    must have a trailing slash.

Fixes #34
This commit is contained in:
Jared Szechy
2014-05-26 12:38:07 -04:00
parent f207eba8f9
commit 4e338dede9
3 changed files with 12 additions and 6 deletions

1
dsd.h
View File

@@ -76,6 +76,7 @@ typedef struct
int playoffset;
char mbe_out_dir[1024];
char mbe_out_file[1024];
char mbe_out_path[1024];
FILE *mbe_out_f;
float audio_gain;
int audio_out;

View File

@@ -168,7 +168,7 @@ void
closeMbeOutFile (dsd_opts * opts, dsd_state * state)
{
char shell[255], newfilename[64], ext[5], datestr[32];
char shell[255], newfilename[64], ext[5], datestr[32], new_path[1024];
char tgid[17];
int sum, i, j;
int talkgroup;
@@ -212,7 +212,8 @@ closeMbeOutFile (dsd_opts * opts, dsd_state * state)
opts->mbe_out_f = NULL;
strftime (datestr, 31, "%Y-%m-%d-%H%M%S", &timep);
sprintf (newfilename, "nac%X-%s-tg%i%s", state->nac, datestr, talkgroup, ext);
sprintf (shell, "mv %s %s", opts->mbe_out_file, newfilename);
sprintf (new_path, "%s%s", opts->mbe_out_dir, newfilename);
sprintf (shell, "mv %s %s", opts->mbe_out_path, new_path);
result = system (shell);
state->tgcount = 0;
@@ -256,10 +257,13 @@ openMbeOutFile (dsd_opts * opts, dsd_state * state)
gettimeofday (&tv, NULL);
sprintf (opts->mbe_out_file, "%i%s", (int) tv.tv_sec, ext);
opts->mbe_out_f = fopen (opts->mbe_out_file, "w");
sprintf(opts->mbe_out_path, "%s%s", opts->mbe_out_dir, opts->mbe_out_file);
opts->mbe_out_f = fopen (opts->mbe_out_path, "w");
if (opts->mbe_out_f == NULL)
{
printf ("Error, couldn't open %s\n", opts->mbe_out_file);
printf ("Error, couldn't open %s\n", opts->mbe_out_path);
}
// write magic
@@ -273,7 +277,7 @@ openWavOutFile (dsd_opts * opts, dsd_state * state)
{
// opts->wav_out_f = fopen (opts->wav_out_file, "w");
SF_INFO info;
info.samplerate = 8000;
info.channels = 1;
@@ -287,7 +291,7 @@ openWavOutFile (dsd_opts * opts, dsd_state * state)
}
// state->wav_out_bytes = 0;
}
void

View File

@@ -103,6 +103,7 @@ initOpts (dsd_opts * opts)
opts->playoffset = 0;
opts->mbe_out_dir[0] = 0;
opts->mbe_out_file[0] = 0;
opts->mbe_out_path[0] = 0;
opts->mbe_out_f = NULL;
opts->audio_gain = 0;
opts->audio_out = 1;