Guest User

Untitled

a guest
Jan 24th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.46 KB | None | 0 0
  1. diff -Naur pianobarfly-2011.01.24a/src/fly.c pianobarfly-2011.01.24b/src/fly.c
  2. --- pianobarfly-2011.01.24a/src/fly.c   2010-12-01 22:34:21.000000000 -0600
  3. +++ pianobarfly-2011.01.24b/src/fly.c   2011-10-13 23:45:20.111297146 -0500
  4. @@ -88,7 +88,7 @@
  5.     int exit_status = 0;
  6.     int status;
  7.     char* file_path = NULL;
  8. -   char dir_path[BAR_FLY_NAME_LENGTH + BAR_FLY_NAME_LENGTH + 2];
  9. +   char dir_path[BAR_FLY_NAME_LENGTH + BAR_FLY_NAME_LENGTH + BAR_FLY_NAME_LENGTH + 3];
  10.     size_t length;
  11.  
  12.     assert(fly != NULL);
  13. @@ -113,6 +113,8 @@
  14.     /*
  15.      * If the parent album and artist directories are empty delete those also.
  16.      */
  17. +
  18. +   // TODO: left off here, how do we make it delete album & artist directories?
  19.     length = _BarFlyNameTranslate(dir_path, fly->artist, BAR_FLY_NAME_LENGTH);
  20.     dir_path[length] = '/';
  21.     _BarFlyNameTranslate(dir_path + length + 1, fly->album,
  22. @@ -153,6 +155,7 @@
  23.     char artist[BAR_FLY_NAME_LENGTH];
  24.     char album[BAR_FLY_NAME_LENGTH];
  25.     char title[BAR_FLY_NAME_LENGTH];
  26. +   char station[BAR_FLY_NAME_LENGTH];
  27.     char const* extension;
  28.  
  29.     assert(fly != NULL);
  30. @@ -164,6 +167,7 @@
  31.     _BarFlyNameTranslate(artist, fly->artist, BAR_FLY_NAME_LENGTH);
  32.     _BarFlyNameTranslate(album, fly->album, BAR_FLY_NAME_LENGTH);
  33.     _BarFlyNameTranslate(title, fly->title, BAR_FLY_NAME_LENGTH);
  34. +   _BarFlyNameTranslate(station, fly->station, BAR_FLY_NAME_LENGTH);
  35.  
  36.     /*
  37.      * Get the extension.
  38. @@ -191,7 +195,7 @@
  39.     /*
  40.      * Get the file path.
  41.      */
  42. -   status = asprintf(&path, "./%s/%s/%s_-_%s.%s", artist, album, artist,
  43. +   status = asprintf(&path, "./%s/%s/%s/%s_-_%s.%s", station, artist, album, artist,
  44.             title, extension);
  45.     if (status == -1) {
  46.         BarUiMsg(MSG_ERR, "Failed to allocate memory.\n");
  47. @@ -466,16 +470,16 @@
  48.     return exit_status;
  49.  }
  50.  
  51. -int BarFlyOpen(BarFly_t* fly, PianoSong_t const* song)
  52. +int BarFlyOpen(BarFly_t* fly, PianoSong_t const* song, PianoStation_t const* station)
  53.  {
  54.     int exit_status = 0;
  55.     BarFly_t output_fly;
  56.     char* file_path = NULL;
  57.  
  58.     /*
  59. -    * artist + '/' + album + '\0'
  60. +    * station + '/' + artist + '/' + album + '\0'
  61.      */
  62. -   char dir_path[BAR_FLY_NAME_LENGTH + BAR_FLY_NAME_LENGTH + 2];
  63. +   char dir_path[BAR_FLY_NAME_LENGTH + BAR_FLY_NAME_LENGTH + BAR_FLY_NAME_LENGTH + 3];
  64.  
  65.     int status;
  66.     struct stat stat_buf;
  67. @@ -491,20 +495,32 @@
  68.     output_fly.completed = false;
  69.  
  70.     /*
  71. -    * Create the artist and album directories.  If they already exist nothing
  72. +    * Create the statio, artist, and album directories.  If they already exist nothing
  73.      * is done.
  74.      */
  75. -   length = _BarFlyNameTranslate(dir_path, song->artist, BAR_FLY_NAME_LENGTH);
  76. +
  77. +   // Create station directory (Classical/)
  78. +   length = _BarFlyNameTranslate(dir_path, station->name, BAR_FLY_NAME_LENGTH);
  79.     dir_path[length] = '/';
  80.     dir_path[length + 1] = '\0';
  81.     status = mkdir(dir_path, 0755);
  82.     if ((status == -1) && (errno != EEXIST)) {
  83. -       BarUiMsg(MSG_ERR, "Unable to create artist directory (%s).\n", dir_path);
  84. +       BarUiMsg(MSG_ERR, "Unable to create station directory (%s).\n", dir_path);
  85.         goto error;
  86.     }
  87.  
  88. -   _BarFlyNameTranslate(dir_path + length + 1, song->album,
  89. -           BAR_FLY_NAME_LENGTH);
  90. +   // Tack on artist (Beethoven,_Ludwig_van/)
  91. +   length += _BarFlyNameTranslate(dir_path + length + 1, song->artist, BAR_FLY_NAME_LENGTH) + 1;
  92. +   dir_path[length] = '/';
  93. +   //dir_path[length+1] = '\0';
  94. +   status = mkdir(dir_path, 0755);
  95. +   if ((status == -1) && (errno != EEXIST)) {
  96. +       BarUiMsg(MSG_ERR, "Unable to create artist directory (%s).\n", dir_path);
  97. +       goto error;
  98. +   }
  99. +  
  100. +   // Tack on album (Gidon_Kremer,_Violin_Sonatas_1-3/)
  101. +   _BarFlyNameTranslate(dir_path + length + 1, song->album, BAR_FLY_NAME_LENGTH);
  102.     status = mkdir(dir_path, 0755);
  103.     if ((status == -1) && (errno != EEXIST)) {
  104.         BarUiMsg(MSG_ERR, "Unable to create album directory (%s).\n", dir_path);
  105. @@ -519,6 +535,8 @@
  106.     /*
  107.      * Copy the artist, album, and title.
  108.      */
  109. +   strncpy(output_fly.station, station->name, BAR_FLY_NAME_LENGTH);
  110. +   output_fly.station[BAR_FLY_NAME_LENGTH - 1] = '\0';
  111.     strncpy(output_fly.artist, song->artist, BAR_FLY_NAME_LENGTH);
  112.     output_fly.artist[BAR_FLY_NAME_LENGTH - 1] = '\0';
  113.     strncpy(output_fly.album, song->album, BAR_FLY_NAME_LENGTH);
  114. diff -Naur pianobarfly-2011.01.24a/src/fly.h pianobarfly-2011.01.24b/src/fly.h
  115. --- pianobarfly-2011.01.24a/src/fly.h   2010-11-29 22:31:14.000000000 -0600
  116. +++ pianobarfly-2011.01.24b/src/fly.h   2011-10-13 22:58:00.690657094 -0500
  117. @@ -72,6 +72,11 @@
  118.      * The song's title.
  119.      */
  120.     char title[BAR_FLY_NAME_LENGTH];
  121. +
  122. +   /**
  123. +    * The current station.
  124. +    */
  125. +   char station[BAR_FLY_NAME_LENGTH];
  126.  } BarFly_t;
  127.  
  128.  
  129. @@ -105,7 +110,7 @@
  130.   * @param song The song for whom the file stream is to be opened.
  131.   * @return Upon success 0 is returned otherwise -1 is returned.
  132.   */
  133. -int BarFlyOpen(BarFly_t* fly, PianoSong_t const* song);
  134. +int BarFlyOpen(BarFly_t* fly, PianoSong_t const* song, PianoStation_t const* station);
  135.  
  136.  /**
  137.   * Marks the audio file as having been fully recorded.  Once the full audio
  138. diff -Naur pianobarfly-2011.01.24a/src/main.c pianobarfly-2011.01.24b/src/main.c
  139. --- pianobarfly-2011.01.24a/src/main.c  2011-01-27 23:06:22.000000000 -0600
  140. +++ pianobarfly-2011.01.24b/src/main.c  2011-10-13 23:00:51.599608955 -0500
  141. @@ -286,7 +286,7 @@
  142.         app->player.audioFormat = app->playlist->audioFormat;
  143.  
  144.         /* Open the audio file. */
  145. -       BarFlyOpen(&app->player.fly, app->playlist);
  146. +       BarFlyOpen(&app->player.fly, app->playlist, app->curStation);
  147.  
  148.         /* throw event */
  149.         BarUiStartEventCmd (&app->settings, "songstart",
Add Comment
Please, Sign In to add comment