diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..f791a2901 --- /dev/null +++ b/CMakeLists.txt @@ -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) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 899a8aee8..76e5d1764 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -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} ) diff --git a/src/core/Library/Base.cpp b/src/core/Library/Base.cpp index b149f4e83..cb35dfc15 100644 --- a/src/core/Library/Base.cpp +++ b/src/core/Library/Base.cpp @@ -33,8 +33,11 @@ // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// - -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif #include diff --git a/src/core/Library/LocalDB.cpp b/src/core/Library/LocalDB.cpp index 62ce1a099..82b1280af 100644 --- a/src/core/Library/LocalDB.cpp +++ b/src/core/Library/LocalDB.cpp @@ -34,7 +34,12 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include #include diff --git a/src/core/Library/Remote.cpp b/src/core/Library/Remote.cpp index 0209a6f18..eaf59fa86 100644 --- a/src/core/Library/Remote.cpp +++ b/src/core/Library/Remote.cpp @@ -34,7 +34,11 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif #include #include #include diff --git a/src/core/Query/Base.cpp b/src/core/Query/Base.cpp index a69d33f7a..775935b01 100644 --- a/src/core/Query/Base.cpp +++ b/src/core/Query/Base.cpp @@ -34,7 +34,11 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif #include #include diff --git a/src/core/Query/Factory.cpp b/src/core/Query/Factory.cpp index 10553130c..415796b12 100644 --- a/src/core/Query/Factory.cpp +++ b/src/core/Query/Factory.cpp @@ -33,7 +33,12 @@ // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include diff --git a/src/core/Query/ListBase.cpp b/src/core/Query/ListBase.cpp index b87ae21d8..70e32b807 100644 --- a/src/core/Query/ListBase.cpp +++ b/src/core/Query/ListBase.cpp @@ -34,7 +34,12 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include #include diff --git a/src/core/Query/ListSelection.cpp b/src/core/Query/ListSelection.cpp index 55af0be66..8c8c68402 100644 --- a/src/core/Query/ListSelection.cpp +++ b/src/core/Query/ListSelection.cpp @@ -34,7 +34,12 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include #include diff --git a/src/core/Query/PlaylistLoad.cpp b/src/core/Query/PlaylistLoad.cpp index 2a33b439f..06b6cd30c 100644 --- a/src/core/Query/PlaylistLoad.cpp +++ b/src/core/Query/PlaylistLoad.cpp @@ -34,7 +34,12 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include diff --git a/src/core/Query/SortTracks.cpp b/src/core/Query/SortTracks.cpp index 0bad55afe..38620938f 100644 --- a/src/core/Query/SortTracks.cpp +++ b/src/core/Query/SortTracks.cpp @@ -34,7 +34,12 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include #include diff --git a/src/core/Query/SortTracksWithData.cpp b/src/core/Query/SortTracksWithData.cpp index 306652110..7efb6c166 100644 --- a/src/core/Query/SortTracksWithData.cpp +++ b/src/core/Query/SortTracksWithData.cpp @@ -34,7 +34,12 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include #include diff --git a/src/core/Query/TrackMetadata.cpp b/src/core/Query/TrackMetadata.cpp index b0de0434b..fa55fc125 100644 --- a/src/core/Query/TrackMetadata.cpp +++ b/src/core/Query/TrackMetadata.cpp @@ -34,7 +34,11 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif #include #include diff --git a/src/core/audio/Buffer.cpp b/src/core/audio/Buffer.cpp index 35164ee58..fcefcdc76 100644 --- a/src/core/audio/Buffer.cpp +++ b/src/core/audio/Buffer.cpp @@ -30,7 +30,12 @@ // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include using namespace musik::core::audio; diff --git a/src/core/audio/Player.cpp b/src/core/audio/Player.cpp index 235cfd005..bf92cdbb0 100644 --- a/src/core/audio/Player.cpp +++ b/src/core/audio/Player.cpp @@ -30,7 +30,12 @@ // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include diff --git a/src/core/audio/Stream.cpp b/src/core/audio/Stream.cpp index 56cceacee..7999d3db4 100644 --- a/src/core/audio/Stream.cpp +++ b/src/core/audio/Stream.cpp @@ -30,7 +30,12 @@ // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include #include diff --git a/src/core/audio/Transport.cpp b/src/core/audio/Transport.cpp index 41c1028b6..41da7bf68 100644 --- a/src/core/audio/Transport.cpp +++ b/src/core/audio/Transport.cpp @@ -30,7 +30,12 @@ // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include using namespace musik::core::audio; diff --git a/src/core/config.h b/src/core/config.h index 03c380796..2c9b1ee52 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -57,7 +57,7 @@ #define STDCALL(fp) __stdcall fp #else - #include + #include typedef unsigned long long UINT64; typedef long long __int64; //TODO: Is this necessary? diff --git a/src/core/db/CachedStatement.cpp b/src/core/db/CachedStatement.cpp index b5c5a57b3..aa0ba38c5 100644 --- a/src/core/db/CachedStatement.cpp +++ b/src/core/db/CachedStatement.cpp @@ -36,7 +36,12 @@ //#pragma once --- Unneccessary -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include #include diff --git a/src/core/db/Connection.cpp b/src/core/db/Connection.cpp index 0c6e61dc4..3b14f0f81 100644 --- a/src/core/db/Connection.cpp +++ b/src/core/db/Connection.cpp @@ -34,7 +34,12 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include #include diff --git a/src/core/db/ScopedTransaction.cpp b/src/core/db/ScopedTransaction.cpp index 8703bd80e..9b28a736b 100644 --- a/src/core/db/ScopedTransaction.cpp +++ b/src/core/db/ScopedTransaction.cpp @@ -34,7 +34,12 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include diff --git a/src/core/db/Statement.cpp b/src/core/db/Statement.cpp index f43cc38c4..30d91d870 100644 --- a/src/core/db/Statement.cpp +++ b/src/core/db/Statement.cpp @@ -36,7 +36,12 @@ //#pragma once --- Unneccessary -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include #include diff --git a/src/core/filestreams/Factory.cpp b/src/core/filestreams/Factory.cpp index 6f6192de6..d61a2e6ee 100644 --- a/src/core/filestreams/Factory.cpp +++ b/src/core/filestreams/Factory.cpp @@ -33,7 +33,12 @@ // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include #include diff --git a/src/core/filestreams/IFileStream.h b/src/core/filestreams/IFileStream.h index e435d96c6..d32de5296 100644 --- a/src/core/filestreams/IFileStream.h +++ b/src/core/filestreams/IFileStream.h @@ -38,6 +38,10 @@ #include #include +#include +#include +#include + ////////////////////////////////////////////////////////////////////////////// namespace musik{ namespace core{ namespace filestreams{ diff --git a/src/core/filestreams/LocalFileStream.cpp b/src/core/filestreams/LocalFileStream.cpp index 8ce7a6e63..629d58257 100644 --- a/src/core/filestreams/LocalFileStream.cpp +++ b/src/core/filestreams/LocalFileStream.cpp @@ -33,7 +33,12 @@ // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include #include @@ -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(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,¤tPosition)==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(){ diff --git a/src/core/filestreams/LocalFileStream.h b/src/core/filestreams/LocalFileStream.h index 81d679cef..af9b2e000 100644 --- a/src/core/filestreams/LocalFileStream.h +++ b/src/core/filestreams/LocalFileStream.h @@ -61,7 +61,10 @@ class LocalFileStream : public IFileStream{ private: utfstring extension; - FILE *file; + FILE *file; + + boost::iostreams::file_descriptor* fd; + boost::iostreams::stream* fileStream; long filesize; diff --git a/src/core/http/RequestParser.cpp b/src/core/http/RequestParser.cpp index b5bf69dab..de4d0b54f 100644 --- a/src/core/http/RequestParser.cpp +++ b/src/core/http/RequestParser.cpp @@ -34,7 +34,12 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include diff --git a/src/core/http/Responder.cpp b/src/core/http/Responder.cpp index 91ef7b388..48c016f1f 100644 --- a/src/core/http/Responder.cpp +++ b/src/core/http/Responder.cpp @@ -34,7 +34,11 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif #include #include diff --git a/src/core/http/Server.cpp b/src/core/http/Server.cpp index aaa381a79..849f2ccf2 100644 --- a/src/core/http/Server.cpp +++ b/src/core/http/Server.cpp @@ -34,7 +34,11 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif #include #include diff --git a/src/core/http/TrackSender.cpp b/src/core/http/TrackSender.cpp index f193dbe17..253a2f316 100644 --- a/src/core/http/TrackSender.cpp +++ b/src/core/http/TrackSender.cpp @@ -34,7 +34,12 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include #include diff --git a/src/core/pch.hpp b/src/core/pch.hpp index 9f7806c69..2da1181b3 100644 --- a/src/core/pch.hpp +++ b/src/core/pch.hpp @@ -43,6 +43,7 @@ #include #include +#include #include #include diff --git a/src/core/server/Connection.cpp b/src/core/server/Connection.cpp index 7ebd9055a..c79faa3af 100644 --- a/src/core/server/Connection.cpp +++ b/src/core/server/Connection.cpp @@ -33,7 +33,12 @@ // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include #include diff --git a/src/core/server/User.cpp b/src/core/server/User.cpp index b0874464a..8fc9b7d7f 100644 --- a/src/core/server/User.cpp +++ b/src/core/server/User.cpp @@ -33,7 +33,12 @@ // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include ////////////////////////////////////////////////////////////////////////////// diff --git a/src/core/server/UserSession.cpp b/src/core/server/UserSession.cpp index e93639188..91d6ed66a 100644 --- a/src/core/server/UserSession.cpp +++ b/src/core/server/UserSession.cpp @@ -33,7 +33,12 @@ // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include ////////////////////////////////////////////////////////////////////////////// diff --git a/src/core/tracklist/Base.cpp b/src/core/tracklist/Base.cpp index ad1bd652f..84cf34bfc 100644 --- a/src/core/tracklist/Base.cpp +++ b/src/core/tracklist/Base.cpp @@ -34,7 +34,12 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include ////////////////////////////////////////////////////////////////////////////// diff --git a/src/core/tracklist/LibraryList.cpp b/src/core/tracklist/LibraryList.cpp index b012f6ccf..0581001b0 100644 --- a/src/core/tracklist/LibraryList.cpp +++ b/src/core/tracklist/LibraryList.cpp @@ -34,7 +34,12 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include #include diff --git a/src/core/tracklist/MultiLibraryList.cpp b/src/core/tracklist/MultiLibraryList.cpp index dd6b12467..2d7127ad4 100644 --- a/src/core/tracklist/MultiLibraryList.cpp +++ b/src/core/tracklist/MultiLibraryList.cpp @@ -34,7 +34,12 @@ // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include #include diff --git a/src/core/xml/Node.cpp b/src/core/xml/Node.cpp index 7eae1206c..e433d1396 100644 --- a/src/core/xml/Node.cpp +++ b/src/core/xml/Node.cpp @@ -33,7 +33,12 @@ // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include "Node.h" #include diff --git a/src/core/xml/Parser.cpp b/src/core/xml/Parser.cpp index 3bb26c118..dc6832a84 100644 --- a/src/core/xml/Parser.cpp +++ b/src/core/xml/Parser.cpp @@ -33,7 +33,12 @@ // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include #include diff --git a/src/core/xml/ParserNode.cpp b/src/core/xml/ParserNode.cpp index 8b6ce6df6..5f03b1893 100644 --- a/src/core/xml/ParserNode.cpp +++ b/src/core/xml/ParserNode.cpp @@ -33,7 +33,12 @@ // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include diff --git a/src/core/xml/Socket.cpp b/src/core/xml/Socket.cpp index 702a132eb..4501be057 100644 --- a/src/core/xml/Socket.cpp +++ b/src/core/xml/Socket.cpp @@ -33,7 +33,12 @@ // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include using namespace musik::core::xml; diff --git a/src/core/xml/Writer.cpp b/src/core/xml/Writer.cpp index 060fe758b..a920b9f1e 100644 --- a/src/core/xml/Writer.cpp +++ b/src/core/xml/Writer.cpp @@ -33,7 +33,12 @@ // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include #include diff --git a/src/core/xml/WriterNode.cpp b/src/core/xml/WriterNode.cpp index 984c1ccee..53a15c09c 100644 --- a/src/core/xml/WriterNode.cpp +++ b/src/core/xml/WriterNode.cpp @@ -33,7 +33,12 @@ // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// -#include "../pch.hpp" +#ifdef WIN32 +#include "pch.hpp" +#else +#include +#endif + #include #include