summaryrefslogtreecommitdiff
path: root/orkbasecxx/audiofile/AudioFile.cpp
blob: 9e2f8b7f00ad015d54112c97786f2b932cd937f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * Oreka -- A media capture and retrieval platform
 * 
 * Copyright (C) 2005, orecx LLC
 *
 * http://www.orecx.com
 *
 * This program is free software, distributed under the terms of
 * the GNU General Public License.
 * Please refer to http://www.gnu.org/copyleft/gpl.html
 *
 */

#include "AudioFile.h"
#include "ace/OS_NS_unistd.h"

void AudioFile::Open(fileOpenModeEnum mode, bool stereo , int sampleRate)
{
	Open(m_filename, mode, stereo, sampleRate);
}


void AudioFile::RecursiveMkdir(CStdString& path)
{
	int position = 0;
	bool done = false;
	while (!done)
	{
		position = path.Find('/', position+1);
		if (position == -1)
		{
			done = true;
		}
		else
		{
			CStdString level = path.Left(position);
			ACE_OS::mkdir((PCSTR)level);
		}
	}
}

void AudioFile::MoveOrig()
{
	CStdString newName = m_filename + ".orig";
	if (ACE_OS::rename((PCSTR)m_filename, (PCSTR)newName) == 0)
	{
		m_filename = newName;
	}
	else
	{
		throw(CStdString("AudioFile::MoveOrig: could not rename file:" + m_filename));
	}
}

void AudioFile::Delete()
{
	ACE_OS::unlink((PCSTR)m_filename);
}

void AudioFile::SetFilename(CStdString& filename)
{
	m_filename = filename;
}


int AudioFile::GetSampleRate()
{
	return m_sampleRate;
}