0ad/source/sound/CPlayList.cpp
janwas 7838627cd2 - vfs_load now returns error code and takes FileIOBuf; that must be freed via file_buf_free. if Handle is needed, use mem_wrap.
- remove ScEd hacks and CFont et al macro rename
- fix accursed bug in VFS buffer management that was causing ReadFile to
fail without error (not allocating enough padding)
- vfs_tree: bugfix in tree_lookup
- waio: temporarily disable sector size determination (pending better
approach - need to determine if using DVD drive)

This was SVN commit r3421.
2006-01-24 08:16:29 +00:00

52 lines
742 B
C++
Executable File

#include "precompiled.h"
#include "CPlayList.h"
#include <stdio.h> // sscanf
#include "lib/res/res.h"
CPlayList::CPlayList(void)
{
tracks.clear();
}
CPlayList::CPlayList(const char* file)
{
load(file);
}
CPlayList::~CPlayList(void)
{
}
void CPlayList::load(const char* file)
{
tracks.clear();
FileIOBuf buf; size_t size;
if(vfs_load(file, buf, size) < 0)
return;
const char* playlist = (const char*)buf;
char track[512];
while(sscanf(playlist, "%511s\n", track) == 1)
tracks.push_back(track);
(void)file_buf_free(buf);
}
void CPlayList::list()
{
for(unsigned int i = 0; i < tracks.size(); i++)
{
debug_printf("%s\n", tracks.at(i).c_str());
}
}
void CPlayList::add(std::string name)
{
tracks.push_back(name);
}