added cutting support for multiple [file-N] segments, re #3
This commit is contained in:
parent
1a8f07de82
commit
ed22b57ef0
|
@ -317,7 +317,7 @@ DarkIce :: configIceCast ( const Config & config,
|
||||||
localDumpName = Util::fileAddDate(localDumpName);
|
localDumpName = Util::fileAddDate(localDumpName);
|
||||||
}
|
}
|
||||||
|
|
||||||
localDumpFile = new FileSink( localDumpName);
|
localDumpFile = new FileSink( stream, localDumpName);
|
||||||
if ( !localDumpFile->exists() ) {
|
if ( !localDumpFile->exists() ) {
|
||||||
if ( !localDumpFile->create() ) {
|
if ( !localDumpFile->create() ) {
|
||||||
reportEvent( 1, "can't create local dump file",
|
reportEvent( 1, "can't create local dump file",
|
||||||
|
@ -519,7 +519,7 @@ DarkIce :: configIceCast2 ( const Config & config,
|
||||||
localDumpName = Util::fileAddDate(localDumpName);
|
localDumpName = Util::fileAddDate(localDumpName);
|
||||||
}
|
}
|
||||||
|
|
||||||
localDumpFile = new FileSink( localDumpName);
|
localDumpFile = new FileSink( stream, localDumpName);
|
||||||
if ( !localDumpFile->exists() ) {
|
if ( !localDumpFile->exists() ) {
|
||||||
if ( !localDumpFile->create() ) {
|
if ( !localDumpFile->create() ) {
|
||||||
reportEvent( 1, "can't create local dump file",
|
reportEvent( 1, "can't create local dump file",
|
||||||
|
@ -762,7 +762,7 @@ DarkIce :: configShoutCast ( const Config & config,
|
||||||
localDumpName = Util::fileAddDate(localDumpName);
|
localDumpName = Util::fileAddDate(localDumpName);
|
||||||
}
|
}
|
||||||
|
|
||||||
localDumpFile = new FileSink( localDumpName);
|
localDumpFile = new FileSink( stream, localDumpName);
|
||||||
if ( !localDumpFile->exists() ) {
|
if ( !localDumpFile->exists() ) {
|
||||||
if ( !localDumpFile->create() ) {
|
if ( !localDumpFile->create() ) {
|
||||||
reportEvent( 1, "can't create local dump file",
|
reportEvent( 1, "can't create local dump file",
|
||||||
|
@ -907,7 +907,7 @@ DarkIce :: configFileCast ( const Config & config )
|
||||||
// go on and create the things
|
// go on and create the things
|
||||||
|
|
||||||
// the underlying file
|
// the underlying file
|
||||||
FileSink * targetFile = new FileSink( targetFileName);
|
FileSink * targetFile = new FileSink( stream, targetFileName);
|
||||||
if ( !targetFile->exists() ) {
|
if ( !targetFile->exists() ) {
|
||||||
if ( !targetFile->create() ) {
|
if ( !targetFile->create() ) {
|
||||||
throw Exception( __FILE__, __LINE__,
|
throw Exception( __FILE__, __LINE__,
|
||||||
|
|
|
@ -118,10 +118,12 @@ static const char fileid[] = "$Id$";
|
||||||
* Initialize the object
|
* Initialize the object
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
FileSink :: init ( const char * name ) throw ( Exception )
|
FileSink :: init ( const char * configName,
|
||||||
|
const char * name ) throw ( Exception )
|
||||||
{
|
{
|
||||||
fileName = Util::strDup( name);
|
this->configName = Util::strDup(configName);
|
||||||
fileDescriptor = 0;
|
fileName = Util::strDup(name);
|
||||||
|
fileDescriptor = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,7 +149,7 @@ FileSink :: FileSink ( const FileSink & fs ) throw ( Exception )
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
init( fs.fileName);
|
init( fs.configName, fs.fileName);
|
||||||
|
|
||||||
if ( (fd = fs.fileDescriptor ? dup( fs.fileDescriptor) : 0) == -1 ) {
|
if ( (fd = fs.fileDescriptor ? dup( fs.fileDescriptor) : 0) == -1 ) {
|
||||||
strip();
|
strip();
|
||||||
|
@ -174,7 +176,7 @@ FileSink :: operator= ( const FileSink & fs ) throw ( Exception )
|
||||||
/* then build up */
|
/* then build up */
|
||||||
Sink::operator=( fs );
|
Sink::operator=( fs );
|
||||||
|
|
||||||
init( fs.fileName);
|
init( fs.configName, fs.fileName);
|
||||||
|
|
||||||
if ( (fd = fs.fileDescriptor ? dup( fs.fileDescriptor) : 0) == -1 ) {
|
if ( (fd = fs.fileDescriptor ? dup( fs.fileDescriptor) : 0) == -1 ) {
|
||||||
strip();
|
strip();
|
||||||
|
@ -311,7 +313,9 @@ FileSink :: write ( const void * buf,
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Get the file name to where to move the data saved so far.
|
* Get the file name to where to move the data saved so far.
|
||||||
* The trick is to read the file name from a file named
|
* The trick is to read the file name from a file named
|
||||||
* /tmp/darkice.$PID , where $PID is the current process id
|
* /tmp/darkice.$configName.$PID , where:
|
||||||
|
* - $configName is the name of the configuration section for this file sink
|
||||||
|
* - $PID is the current process id
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
std::string
|
std::string
|
||||||
FileSink :: getArchiveFileName ( void ) throw ( Exception )
|
FileSink :: getArchiveFileName ( void ) throw ( Exception )
|
||||||
|
@ -319,7 +323,7 @@ FileSink :: getArchiveFileName ( void ) throw ( Exception )
|
||||||
pid_t pid = getpid();
|
pid_t pid = getpid();
|
||||||
std::stringstream metaFileName;
|
std::stringstream metaFileName;
|
||||||
|
|
||||||
metaFileName << "/tmp/darkice." << pid;
|
metaFileName << "/tmp/darkice." << configName << "." << pid;
|
||||||
|
|
||||||
std::ifstream ifs(metaFileName.str().c_str());
|
std::ifstream ifs(metaFileName.str().c_str());
|
||||||
if (!ifs.good()) {
|
if (!ifs.good()) {
|
||||||
|
|
|
@ -58,6 +58,12 @@ class FileSink : public Sink, public virtual Reporter
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the configuration related to
|
||||||
|
* this file sink. something like "file-0" or "file-2".
|
||||||
|
*/
|
||||||
|
char * configName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the file represented by the FileSink.
|
* Name of the file represented by the FileSink.
|
||||||
*/
|
*/
|
||||||
|
@ -66,11 +72,14 @@ class FileSink : public Sink, public virtual Reporter
|
||||||
/**
|
/**
|
||||||
* Initialize the object.
|
* Initialize the object.
|
||||||
*
|
*
|
||||||
|
* @param configName the name of the configuration related to
|
||||||
|
* this file sink. something like "file-0" or "file-2".
|
||||||
* @param name name of the file to be represented by the object.
|
* @param name name of the file to be represented by the object.
|
||||||
* @exception Exception
|
* @exception Exception
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
init ( const char * name ) throw ( Exception );
|
init ( const char * configName,
|
||||||
|
const char * name ) throw ( Exception );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* De-initialize the object.
|
* De-initialize the object.
|
||||||
|
@ -115,13 +124,16 @@ class FileSink : public Sink, public virtual Reporter
|
||||||
/**
|
/**
|
||||||
* Constructor by a file name.
|
* Constructor by a file name.
|
||||||
*
|
*
|
||||||
|
* @param configName the name of the configuration related to
|
||||||
|
* this file sink. something like "file-0" or "file-2".
|
||||||
* @param name name of the file to be represented by the object.
|
* @param name name of the file to be represented by the object.
|
||||||
* @exception Exception
|
* @exception Exception
|
||||||
*/
|
*/
|
||||||
inline
|
inline
|
||||||
FileSink( const char * name ) throw ( Exception )
|
FileSink( const char * configName,
|
||||||
|
const char * name ) throw ( Exception )
|
||||||
{
|
{
|
||||||
init( name);
|
init( configName, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue