export data to build/sync/data

This commit is contained in:
Kuba Winnicki 2016-06-15 09:09:34 +02:00
parent 5e4c1a185c
commit 4a9056bba8

View File

@ -1,6 +1,7 @@
#include "device.h"
#include "track.h"
#include <stdio.h>
#include <fcntl.h>
#include <math.h>
#include <assert.h>
#include <string.h>
@ -264,6 +265,14 @@ static int get_track_data(struct sync_device *d, struct sync_track *t)
static int save_track(const struct sync_track *t, const char *path)
{
int i;
int cwd = open(".", O_RDONLY);
if (!cwd)
return -1;
if (!chdir("build/sync"))
return -1;
FILE *fp = fopen(path, "wb");
if (!fp)
return -1;
@ -277,6 +286,9 @@ static int save_track(const struct sync_track *t, const char *path)
}
fclose(fp);
if (!fchdir(cwd))
return -1;
return 0;
}