I want to be able to use shntool split even if there is no split points
(i.e. there is only one track in cue sheet) but I can't. It's not so
pointless as it may seem to be - this may be useful when running
cue2tracks script for multiple albums and some of them may contain only
one track.
The patch introduces flag -F to force splitting:
--- src/mode_split.c 2008-02-19 02:25:14.000000000 +0300
+++ src/mode_split.c 2012-03-10 16:58:44.000000000 +0400
@@ -57,6 +57,7 @@
static char *leadout = NULL;
static char *extract_tracks = NULL;
static char *manipulate_chars = NULL;
+static int force_split = 0;
typedef struct _cue_info {
/* global */
@@ -101,6 +102,7 @@
st_info(" (%%p = performer, %%a = album, %%t = track title, %%n = track number)\n");
st_info(" -u len postfix each track with len amount of lead-out from next track (*)\n");
st_info(" -x list only extract tracks in list (comma-separated, may contain ranges)\n");
+ st_info(" -F force split even if no split points are given (outputs one file)\n");
st_info("\n");
st_info(" (*) len must be in bytes, m:ss, m:ss.ff or m:ss.nnn format\n");
st_info("\n");
@@ -116,7 +118,7 @@
st_ops.output_prefix = SPLIT_PREFIX;
cueinfo.format = NULL;
- while ((c = st_getopt(argc,argv,"c:e:f:l:n:m:t:u:x:")) != -1) {
+ while ((c = st_getopt(argc,argv,"c:e:f:l:n:m:t:u:x:F")) != -1) {
switch (c) {
case 'c':
if (NULL == optarg)
@@ -168,6 +170,9 @@
st_error("missing track numbers to extract");
extract_tracks = optarg;
break;
+ case 'F':
+ force_split = 1;
+ break;
}
}
@@ -736,8 +741,14 @@
if (split_point_file)
fclose(fd);
- if (1 == numfiles)
- st_error("no split points given -- nothing to do");
+ if (1 == numfiles) {
+ if (force_split) {
+ st_warning("no split points given");
+ }
+ else {
+ st_error("no split points given -- nothing to do");
+ }
+ }
if (SPLIT_INPUT_CUE == input_type && cueinfo.format) {
if (cueinfo.trackno < numfiles)
@@ -860,16 +871,16 @@
else
read_split_points_file(info);
- if (files[numfiles-2]->beginning_byte > info->data_size)
+ if (numfiles > 1 && files[numfiles-2]->beginning_byte > info->data_size)
st_error("split points go beyond input file's data size");
- if (files[numfiles-2]->beginning_byte == info->data_size) {
+ if (numfiles > 1 && files[numfiles-2]->beginning_byte == info->data_size) {
st_free(files[numfiles-1]);
numfiles--;
}
else {
files[numfiles-1]->beginning_byte = info->data_size;
- files[numfiles-1]->data_size = info->data_size - files[numfiles-2]->beginning_byte;
+ files[numfiles-1]->data_size = info->data_size - (numfiles > 1 ? files[numfiles-2]->beginning_byte : 0);
adjust_splitfile(numfiles-1);
}