[Summary] Fixed export on windows: made tmp files deleted

[Reviewed by] VKamyshniy
This commit is contained in:
Greg Zharun 2014-12-24 17:55:17 +02:00
parent 6edcd4064b
commit 6dd3b0d95f
2 changed files with 20 additions and 1 deletions

View file

@ -35,7 +35,10 @@ class TmpFile : public SndfileWriter<T>, public SndfileReader<T>
~TmpFile()
{
if (!filename.empty()) {
std::remove(filename.c_str());
SndfileHandle::close();
if (std::remove(filename.c_str() ) != 0) {
std::cout << "TmpFile::~TmpFile () : Error removing temp file: " << strerror(errno) << std::endl;
}
}
}

View file

@ -94,6 +94,8 @@ class SndfileHandle
bool operator == (const SndfileHandle &rhs) const { return (p == rhs.p) ; }
int close (void);
sf_count_t frames (void) const { return p ? p->sfinfo.frames : 0 ; }
int format (void) const { return p ? p->sfinfo.format : 0 ; }
int channels (void) const { return p ? p->sfinfo.channels : 0 ; }
@ -250,6 +252,20 @@ SndfileHandle::operator = (const SndfileHandle &rhs)
return *this ;
} /* SndfileHandle assignment operator */
int
SndfileHandle::close (void)
{
if ( (p->sf != NULL) && (sf_close (p->sf) == 0 ) )
{
p->sf = NULL;
return 0;
}
else
{
return -1 ;
}
}
inline int
SndfileHandle::error (void) const
{ return sf_error (p->sf) ; }