Changed filestreams to use boost filestreams for portability. Also core now compiles and links completely under linux :).

This commit is contained in:
Urioxis 2009-05-06 09:12:12 +00:00
parent b2b7aee425
commit ef68e9f271
43 changed files with 274 additions and 60 deletions

8
CMakeLists.txt Normal file
View File

@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 2.6)
project( musikCube )
SET (CMAKE_BUILD_TYPE DEBUG)
set (LIBRARY_OUTPUT_PATH ${musikCube_SOURCE_DIR}/lib)
set (EXECUTABLE_OUTPUT_PATH ${musikCibe_SOURCE_DIR}/bin)
add_subdirectory(src/core)

View File

@ -1,9 +1,4 @@
cmake_minimum_required(VERSION 2.6)
project( core )
SET (CMAKE_BUILD_TYPE DEBUG)
set(SOURCES
set(CORE_SOURCES
pch.cpp
pch.hpp
PlaybackQueue.cpp
@ -63,14 +58,10 @@ set(SOURCES
TrackFactory.cpp
)
set (WINDOWS_EXTRAS
)
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
add_definitions(-DWIN32)
if(NOT DEFINED MINGW)
SET(SOURCES ${SOURCES} ${WINDOWS_EXTRAS})
endif(NOT DEFINED MINGW)
else(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fpermissive)
@ -89,5 +80,5 @@ add_definitions(
-D_DEBUG
)
add_library( core SHARED ${SOURCES} )
add_library( core SHARED ${CORE_SOURCES} )

View File

@ -33,8 +33,11 @@
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/Library/Base.h>

View File

@ -34,7 +34,12 @@
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/Library/LocalDB.h>
#include <core/Query/Base.h>
#include <core/Preferences.h>

View File

@ -34,7 +34,11 @@
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/Common.h>
#include <core/Library/Remote.h>
#include <core/Query/Base.h>

View File

@ -34,7 +34,11 @@
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/Query/Base.h>
#include <core/Library/Base.h>

View File

@ -33,7 +33,12 @@
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/Query/Factory.h>
#include <core/Query/ListSelection.h>

View File

@ -34,7 +34,12 @@
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/Query/ListBase.h>
#include <core/Library/Base.h>
#include <core/Common.h>

View File

@ -34,7 +34,12 @@
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/Query/ListSelection.h>
#include <core/Library/Base.h>
#include <core/xml/ParserNode.h>

View File

@ -34,7 +34,12 @@
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/Query/PlaylistLoad.h>
#include <core/Library/Base.h>

View File

@ -34,7 +34,12 @@
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/Query/SortTracks.h>
#include <core/Library/Base.h>
#include <core/config_format.h>

View File

@ -34,7 +34,12 @@
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/Query/SortTracksWithData.h>
#include <core/Library/Base.h>
#include <core/config_format.h>

View File

@ -34,7 +34,11 @@
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/Common.h>
#include <core/Query/TrackMetadata.h>

View File

@ -30,7 +30,12 @@
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/audio/Buffer.h>
using namespace musik::core::audio;

View File

@ -30,7 +30,12 @@
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/audio/Player.h>
#include <core/PluginFactory.h>

View File

@ -30,7 +30,12 @@
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/audio/Stream.h>
#include <core/audio/IDecoderFactory.h>
#include <core/PluginFactory.h>

View File

@ -30,7 +30,12 @@
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/audio/Transport.h>
using namespace musik::core::audio;

View File

@ -57,7 +57,7 @@
#define STDCALL(fp) __stdcall fp
#else
#include <assert.h>
#include <cassert>
typedef unsigned long long UINT64;
typedef long long __int64; //TODO: Is this necessary?

View File

@ -36,7 +36,12 @@
//#pragma once --- Unneccessary
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/db/CachedStatement.h>
#include <core/db/Statement.h>
#include <core/db/Connection.h>

View File

@ -34,7 +34,12 @@
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/db/Connection.h>
#include <boost/lexical_cast.hpp>
#include <boost/thread/thread.hpp>

View File

@ -34,7 +34,12 @@
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/db/ScopedTransaction.h>
#include <core/db/Connection.h>

View File

@ -36,7 +36,12 @@
//#pragma once --- Unneccessary
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/db/Statement.h>
#include <core/db/Connection.h>
#include <sqlite/sqlite3.h>

View File

@ -33,7 +33,12 @@
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/filestreams/Factory.h>
#include <core/config_filesystem.h>
#include <core/PluginFactory.h>

View File

@ -38,6 +38,10 @@
#include <core/config.h>
#include <boost/shared_ptr.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/stream_buffer.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>
//////////////////////////////////////////////////////////////////////////////
namespace musik{ namespace core{ namespace filestreams{

View File

@ -33,7 +33,12 @@
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/filestreams/LocalFileStream.h>
#include <core/config.h>
#include <core/config_filesystem.h>
@ -71,9 +76,12 @@ bool LocalFileStream::Open(const utfchar *filename,unsigned int options){
boost::filesystem::utfpath file(filename);
this->filesize = (long)boost::filesystem::file_size(file);
this->extension = file.extension();
this->file = UTFFopen(filename,UTF("rb"));
// this->file = UTFFopen(filename,UTF("rb"));
this->fd = new boost::iostreams::file_descriptor(filename);
this->fileStream = new boost::iostreams::stream<boost::iostreams::file_descriptor>(this->fd);
this->fileStream->exceptions ( std::ios_base::eofbit | std::ios_base::failbit | std::ios_base::badbit );
return this->file!=NULL;
}
catch(...){
return false;
@ -84,6 +92,8 @@ bool LocalFileStream::Close(){
if(this->file){
if(fclose(this->file)==0){
this->file = NULL;
delete this->fd;
delete this->fileStream;
return true;
}
}
@ -95,24 +105,48 @@ void LocalFileStream::Destroy(){
}
PositionType LocalFileStream::Read(void* buffer,PositionType readBytes){
return (PositionType)fread(buffer,1,readBytes,this->file);
//return (PositionType)fread(buffer,1,readBytes,this->file);
try {
this->fileStream->read((char*)buffer, readBytes);
}
catch (std::ios_base::failure) {
if(this->fileStream->eof()) {
//EOF reached
return sizeof(buffer);
}
else {
std::cerr << "Error reading from file" << std::endl;
}
return 0;
}
return readBytes;
}
bool LocalFileStream::SetPosition(PositionType position){
stdioPositionType newPosition = (stdioPositionType)position;
return fsetpos(this->file,&newPosition)==0;
/*stdioPositionType newPosition = (stdioPositionType)position;
return fsetpos(this->file,&newPosition)==0;*/
try {
this->fileStream->seekp(position);
this->fileStream->seekg(position);
}
catch (std::ios_base::failure) {
return false;
}
return true;
}
PositionType LocalFileStream::Position(){
stdioPositionType currentPosition(0);
/*stdioPositionType currentPosition(0);
if(fgetpos(this->file,&currentPosition)==0){
return (PositionType)currentPosition;
}
return -1;
return -1;*/
return this->fileStream->tellg();
}
bool LocalFileStream::Eof(){
return feof(this->file)!=0;
//return feof(this->file)!=0;
return this->fileStream->eof();
}
long LocalFileStream::Filesize(){

View File

@ -61,7 +61,10 @@ class LocalFileStream : public IFileStream{
private:
utfstring extension;
FILE *file;
FILE *file;
boost::iostreams::file_descriptor* fd;
boost::iostreams::stream<boost::iostreams::file_descriptor>* fileStream;
long filesize;

View File

@ -34,7 +34,12 @@
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/http/RequestParser.h>
#include <boost/algorithm/string.hpp>

View File

@ -34,7 +34,11 @@
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/http/Responder.h>
#include <core/http/Server.h>

View File

@ -34,7 +34,11 @@
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/http/Server.h>
#include <core/http/Responder.h>

View File

@ -34,7 +34,12 @@
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/http/TrackSender.h>
#include <core/Common.h>
#include <core/filestreams/Factory.h>

View File

@ -43,6 +43,7 @@
#include <sigslot/sigslot.h>
#include <boost/shared_ptr.hpp>
#include <boost/iostreams/stream.hpp>
#include <core/db/Connection.h>
#include <core/db/Statement.h>

View File

@ -33,7 +33,12 @@
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/server/Connection.h>
#include <core/Common.h>
#include <core/Preferences.h>

View File

@ -33,7 +33,12 @@
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/server/User.h>
//////////////////////////////////////////////////////////////////////////////

View File

@ -33,7 +33,12 @@
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/server/UserSession.h>
//////////////////////////////////////////////////////////////////////////////

View File

@ -34,7 +34,12 @@
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/tracklist/Base.h>
//////////////////////////////////////////////////////////////////////////////

View File

@ -34,7 +34,12 @@
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/tracklist/LibraryList.h>
#include <core/LibraryTrack.h>
#include <core/Query/SortTracks.h>

View File

@ -34,7 +34,12 @@
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/tracklist/MultiLibraryList.h>
#include <core/LibraryTrack.h>
#include <core/LibraryFactory.h>

View File

@ -33,7 +33,12 @@
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include "Node.h"
#include <core/xml/Parser.h>

View File

@ -33,7 +33,12 @@
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/xml/Parser.h>
#include <core/xml/ParserNode.h>
#include <expat/expat.h>

View File

@ -33,7 +33,12 @@
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/xml/ParserNode.h>
#include <core/xml/Parser.h>

View File

@ -33,7 +33,12 @@
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/xml/Socket.h>
using namespace musik::core::xml;

View File

@ -33,7 +33,12 @@
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/xml/Writer.h>
#include <core/xml/WriterNode.h>
#include <boost/algorithm/string/replace.hpp>

View File

@ -33,7 +33,12 @@
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "../pch.hpp"
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/xml/WriterNode.h>
#include <core/xml/Writer.h>