cosmetic changes to the fileAddDate option

This commit is contained in:
darkeye 2003-02-09 12:57:36 +00:00
parent b6b181d5fb
commit 6253785062
4 changed files with 80 additions and 62 deletions

View File

@ -1,4 +1,4 @@
.TH darkice.cfg 5 "August 20, 2002" "DarkIce" "DarkIce live audio streamer" .TH darkice.cfg 5 "February 9, 2003" "DarkIce" "DarkIce live audio streamer"
.SH NAME .SH NAME
darkice.cfg \- configuration file for darkice darkice.cfg \- configuration file for darkice
.SH DESCRIPTION .SH DESCRIPTION
@ -158,8 +158,8 @@ server to this local file.
.TP .TP
.I fileAddDate .I fileAddDate
"yes" or "no" if you want to automaticaly insert a date string in "yes" or "no" if you want to automaticaly insert a date string in
the file name before his extension or at the end of file name if file name the localDumpFile name before its extension or at the end of file name if
doens't have an extension. no extension present
.TP .TP
.I lowpass .I lowpass
Lowpass filter setting for the lame encoder. If not set or set to 0, Lowpass filter setting for the lame encoder. If not set or set to 0,
@ -264,8 +264,8 @@ server to this local file.
.TP .TP
.I fileAddDate .I fileAddDate
"yes" or "no" if you want to automaticaly insert a date string in "yes" or "no" if you want to automaticaly insert a date string in
the file name before his extension or at the end of file name if file name the localDumpFile name before its extension or at the end of file name if
doens't have an extension. no extension present
.PP .PP
.B [shoutcast-x] .B [shoutcast-x]
@ -359,8 +359,8 @@ server to this local file.
.TP .TP
.I fileAddDate .I fileAddDate
"yes" or "no" if you want to automaticaly insert a date string in "yes" or "no" if you want to automaticaly insert a date string in
the file name before his extension or at the end of file name if file name the localDumpFile name before its extension or at the end of file name if
doens't have an extension. no extension present
.PP .PP
.B [file-x] .B [file-x]

View File

@ -292,9 +292,9 @@ DarkIce :: configIceCast ( const Config & config,
// check for and create the local dump file if needed // check for and create the local dump file if needed
if ( localDumpName != 0 ) { if ( localDumpName != 0 ) {
if ( fileAddDate ) {
if (fileAddDate)
localDumpName = Util::fileAddDate(localDumpName); localDumpName = Util::fileAddDate(localDumpName);
}
localDumpFile = new FileSink( localDumpName); localDumpFile = new FileSink( localDumpName);
if ( !localDumpFile->exists() ) { if ( !localDumpFile->exists() ) {
@ -304,6 +304,9 @@ DarkIce :: configIceCast ( const Config & config,
localDumpFile = 0; localDumpFile = 0;
} }
} }
if ( fileAddDate ) {
delete[] localDumpFile;
}
} }
// streaming related stuff // streaming related stuff
audioOuts[u].socket = new TcpSocket( server, port); audioOuts[u].socket = new TcpSocket( server, port);
@ -455,9 +458,9 @@ DarkIce :: configIceCast2 ( const Config & config,
// check for and create the local dump file if needed // check for and create the local dump file if needed
if ( localDumpName != 0 ) { if ( localDumpName != 0 ) {
if ( fileAddDate ) {
if (fileAddDate)
localDumpName = Util::fileAddDate(localDumpName); localDumpName = Util::fileAddDate(localDumpName);
}
localDumpFile = new FileSink( localDumpName); localDumpFile = new FileSink( localDumpName);
if ( !localDumpFile->exists() ) { if ( !localDumpFile->exists() ) {
@ -467,7 +470,11 @@ DarkIce :: configIceCast2 ( const Config & config,
localDumpFile = 0; localDumpFile = 0;
} }
} }
if ( fileAddDate ) {
delete[] localDumpName;
} }
}
// streaming related stuff // streaming related stuff
audioOuts[u].socket = new TcpSocket( server, port); audioOuts[u].socket = new TcpSocket( server, port);
audioOuts[u].server = new IceCast2( audioOuts[u].socket.get(), audioOuts[u].server = new IceCast2( audioOuts[u].socket.get(),
@ -649,16 +656,15 @@ DarkIce :: configShoutCast ( const Config & config,
str = cs->get("fileAddDate"); str = cs->get("fileAddDate");
fileAddDate = str ? (Util::strEq( str, "yes") ? true : false) : false; fileAddDate = str ? (Util::strEq( str, "yes") ? true : false) : false;
localDumpName = cs->get( "localDumpFile"); localDumpName = cs->get( "localDumpFile");
// go on and create the things // go on and create the things
// check for and create the local dump file if needed // check for and create the local dump file if needed
if ( localDumpName != 0 ) { if ( localDumpName != 0 ) {
if ( fileAddDate ) {
if (fileAddDate)
localDumpName = Util::fileAddDate(localDumpName); localDumpName = Util::fileAddDate(localDumpName);
}
localDumpFile = new FileSink( localDumpName); localDumpFile = new FileSink( localDumpName);
if ( !localDumpFile->exists() ) { if ( !localDumpFile->exists() ) {
@ -668,6 +674,9 @@ DarkIce :: configShoutCast ( const Config & config,
localDumpFile = 0; localDumpFile = 0;
} }
} }
if ( fileAddDate ) {
delete[] localDumpFile;
}
} }
// streaming related stuff // streaming related stuff
@ -987,6 +996,9 @@ DarkIce :: run ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.34 2003/02/09 12:57:36 darkeye
cosmetic changes to the fileAddDate option
Revision 1.33 2002/11/20 16:52:05 wandereq Revision 1.33 2002/11/20 16:52:05 wandereq
added fileAddDate function added fileAddDate function

View File

@ -267,9 +267,8 @@ Util :: strToD( const char * str ) throw ( Exception )
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* insert date between 2 string pointers * add current date to a file name, before the file extension (if any)
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
char * char *
Util :: fileAddDate ( const char * str ) throw ( Exception ) Util :: fileAddDate ( const char * str ) throw ( Exception )
{ {
@ -283,25 +282,26 @@ Util :: fileAddDate ( const char * str ) throw ( Exception )
throw Exception( __FILE__, __LINE__, "no str"); throw Exception( __FILE__, __LINE__, "no str");
} }
strdate = new char[128]; strdate = new char[128];
now = time(NULL); now = time(NULL);
strftime( strdate, 128, "[%m-%d-%Y-%H-%M-%S]", localtime (&now)); strftime( strdate, 128, "[%m-%d-%Y-%H-%M-%S]", localtime (&now));
last = strrchr (str,'.'); // search for the part before the extension of the file name
if (last == NULL) if ( !(last = strrchr( str, '.')) ) {
last = (char *) str + strlen( str); last = (char *) str + strlen( str);
}
size = strlen( str) + strlen( strdate) + 1; size = strlen( str) + strlen( strdate) + 1;
s = new char [size]; s = new char [size];
memcpy( s, str, strlen (str)-strlen(last)); memcpy( s, str, strlen (str)-strlen(last));
memcpy( s + strlen(str) - strlen(last), strdate, strlen (strdate)); memcpy( s + strlen(str) - strlen(last), strdate, strlen (strdate));
memcpy (s + strlen(str) - strlen(last) + strlen(strdate), last,strlen(last)); memcpy( s + strlen(str) - strlen(last) + strlen(strdate),
last,
strlen(last));
s[size-1] = '\0'; s[size-1] = '\0';
delete strdate; delete[] strdate;
return s; return s;
} }
@ -493,6 +493,9 @@ Util :: conv16 ( unsigned char * pcmBuffer,
$Source$ $Source$
$Log$ $Log$
Revision 1.12 2003/02/09 12:57:36 darkeye
cosmetic changes to the fileAddDate option
Revision 1.11 2002/12/22 01:20:32 darkeye Revision 1.11 2002/12/22 01:20:32 darkeye
time.h include file was missing time.h include file was missing

View File

@ -203,14 +203,14 @@ class Util
strToD ( const char * str ) throw ( Exception ); strToD ( const char * str ) throw ( Exception );
/** /**
* Add a date to a string * Add current date to a file name, before the file extension (if any)
* *
* @param str the string to convert (file name). * @param str the string to convert (file name).
* @return the new string with the date appended before * @return the new string with the date appended before
* extension of the file name * extension of the file name. the string has to be
* deleted with delete[] after it is not needed
* @exception Exception * @exception Exception
*/ */
static char * static char *
fileAddDate ( const char * str ) throw ( Exception ); fileAddDate ( const char * str ) throw ( Exception );
@ -319,6 +319,9 @@ class Util
$Source$ $Source$
$Log$ $Log$
Revision 1.9 2003/02/09 12:57:36 darkeye
cosmetic changes to the fileAddDate option
Revision 1.8 2002/11/20 16:52:08 wandereq Revision 1.8 2002/11/20 16:52:08 wandereq
added fileAddDate function added fileAddDate function