Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -Naur pianobarfly-2011.01.24a/src/fly.c pianobarfly-2011.01.24b/src/fly.c
- --- pianobarfly-2011.01.24a/src/fly.c 2010-12-01 22:34:21.000000000 -0600
- +++ pianobarfly-2011.01.24b/src/fly.c 2011-10-13 23:45:20.111297146 -0500
- @@ -88,7 +88,7 @@
- int exit_status = 0;
- int status;
- char* file_path = NULL;
- - char dir_path[BAR_FLY_NAME_LENGTH + BAR_FLY_NAME_LENGTH + 2];
- + char dir_path[BAR_FLY_NAME_LENGTH + BAR_FLY_NAME_LENGTH + BAR_FLY_NAME_LENGTH + 3];
- size_t length;
- assert(fly != NULL);
- @@ -113,6 +113,8 @@
- /*
- * If the parent album and artist directories are empty delete those also.
- */
- +
- + // TODO: left off here, how do we make it delete album & artist directories?
- length = _BarFlyNameTranslate(dir_path, fly->artist, BAR_FLY_NAME_LENGTH);
- dir_path[length] = '/';
- _BarFlyNameTranslate(dir_path + length + 1, fly->album,
- @@ -153,6 +155,7 @@
- char artist[BAR_FLY_NAME_LENGTH];
- char album[BAR_FLY_NAME_LENGTH];
- char title[BAR_FLY_NAME_LENGTH];
- + char station[BAR_FLY_NAME_LENGTH];
- char const* extension;
- assert(fly != NULL);
- @@ -164,6 +167,7 @@
- _BarFlyNameTranslate(artist, fly->artist, BAR_FLY_NAME_LENGTH);
- _BarFlyNameTranslate(album, fly->album, BAR_FLY_NAME_LENGTH);
- _BarFlyNameTranslate(title, fly->title, BAR_FLY_NAME_LENGTH);
- + _BarFlyNameTranslate(station, fly->station, BAR_FLY_NAME_LENGTH);
- /*
- * Get the extension.
- @@ -191,7 +195,7 @@
- /*
- * Get the file path.
- */
- - status = asprintf(&path, "./%s/%s/%s_-_%s.%s", artist, album, artist,
- + status = asprintf(&path, "./%s/%s/%s/%s_-_%s.%s", station, artist, album, artist,
- title, extension);
- if (status == -1) {
- BarUiMsg(MSG_ERR, "Failed to allocate memory.\n");
- @@ -466,16 +470,16 @@
- return exit_status;
- }
- -int BarFlyOpen(BarFly_t* fly, PianoSong_t const* song)
- +int BarFlyOpen(BarFly_t* fly, PianoSong_t const* song, PianoStation_t const* station)
- {
- int exit_status = 0;
- BarFly_t output_fly;
- char* file_path = NULL;
- /*
- - * artist + '/' + album + '\0'
- + * station + '/' + artist + '/' + album + '\0'
- */
- - char dir_path[BAR_FLY_NAME_LENGTH + BAR_FLY_NAME_LENGTH + 2];
- + char dir_path[BAR_FLY_NAME_LENGTH + BAR_FLY_NAME_LENGTH + BAR_FLY_NAME_LENGTH + 3];
- int status;
- struct stat stat_buf;
- @@ -491,20 +495,32 @@
- output_fly.completed = false;
- /*
- - * Create the artist and album directories. If they already exist nothing
- + * Create the statio, artist, and album directories. If they already exist nothing
- * is done.
- */
- - length = _BarFlyNameTranslate(dir_path, song->artist, BAR_FLY_NAME_LENGTH);
- +
- + // Create station directory (Classical/)
- + length = _BarFlyNameTranslate(dir_path, station->name, BAR_FLY_NAME_LENGTH);
- dir_path[length] = '/';
- dir_path[length + 1] = '\0';
- status = mkdir(dir_path, 0755);
- if ((status == -1) && (errno != EEXIST)) {
- - BarUiMsg(MSG_ERR, "Unable to create artist directory (%s).\n", dir_path);
- + BarUiMsg(MSG_ERR, "Unable to create station directory (%s).\n", dir_path);
- goto error;
- }
- - _BarFlyNameTranslate(dir_path + length + 1, song->album,
- - BAR_FLY_NAME_LENGTH);
- + // Tack on artist (Beethoven,_Ludwig_van/)
- + length += _BarFlyNameTranslate(dir_path + length + 1, song->artist, BAR_FLY_NAME_LENGTH) + 1;
- + dir_path[length] = '/';
- + //dir_path[length+1] = '\0';
- + status = mkdir(dir_path, 0755);
- + if ((status == -1) && (errno != EEXIST)) {
- + BarUiMsg(MSG_ERR, "Unable to create artist directory (%s).\n", dir_path);
- + goto error;
- + }
- +
- + // Tack on album (Gidon_Kremer,_Violin_Sonatas_1-3/)
- + _BarFlyNameTranslate(dir_path + length + 1, song->album, BAR_FLY_NAME_LENGTH);
- status = mkdir(dir_path, 0755);
- if ((status == -1) && (errno != EEXIST)) {
- BarUiMsg(MSG_ERR, "Unable to create album directory (%s).\n", dir_path);
- @@ -519,6 +535,8 @@
- /*
- * Copy the artist, album, and title.
- */
- + strncpy(output_fly.station, station->name, BAR_FLY_NAME_LENGTH);
- + output_fly.station[BAR_FLY_NAME_LENGTH - 1] = '\0';
- strncpy(output_fly.artist, song->artist, BAR_FLY_NAME_LENGTH);
- output_fly.artist[BAR_FLY_NAME_LENGTH - 1] = '\0';
- strncpy(output_fly.album, song->album, BAR_FLY_NAME_LENGTH);
- diff -Naur pianobarfly-2011.01.24a/src/fly.h pianobarfly-2011.01.24b/src/fly.h
- --- pianobarfly-2011.01.24a/src/fly.h 2010-11-29 22:31:14.000000000 -0600
- +++ pianobarfly-2011.01.24b/src/fly.h 2011-10-13 22:58:00.690657094 -0500
- @@ -72,6 +72,11 @@
- * The song's title.
- */
- char title[BAR_FLY_NAME_LENGTH];
- +
- + /**
- + * The current station.
- + */
- + char station[BAR_FLY_NAME_LENGTH];
- } BarFly_t;
- @@ -105,7 +110,7 @@
- * @param song The song for whom the file stream is to be opened.
- * @return Upon success 0 is returned otherwise -1 is returned.
- */
- -int BarFlyOpen(BarFly_t* fly, PianoSong_t const* song);
- +int BarFlyOpen(BarFly_t* fly, PianoSong_t const* song, PianoStation_t const* station);
- /**
- * Marks the audio file as having been fully recorded. Once the full audio
- diff -Naur pianobarfly-2011.01.24a/src/main.c pianobarfly-2011.01.24b/src/main.c
- --- pianobarfly-2011.01.24a/src/main.c 2011-01-27 23:06:22.000000000 -0600
- +++ pianobarfly-2011.01.24b/src/main.c 2011-10-13 23:00:51.599608955 -0500
- @@ -286,7 +286,7 @@
- app->player.audioFormat = app->playlist->audioFormat;
- /* Open the audio file. */
- - BarFlyOpen(&app->player.fly, app->playlist);
- + BarFlyOpen(&app->player.fly, app->playlist, app->curStation);
- /* throw event */
- BarUiStartEventCmd (&app->settings, "songstart",
Add Comment
Please, Sign In to add comment