commit 9dcf70b157bdbac915e058eaa95e48a2af13b2a0 Author: amazing-username Date: Sun Mar 17 17:05:27 2019 -0400 Initial commit of IcarusDownloadManager diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c3af806 --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +IcarusDownloadManager: src/Main.cpp src/Managers/FileManager.h src/Managers/FileManager.cpp src/Syncers/Upload.h src/Syncers/Upload.cpp src/Models/Song.h + g++ -std=c++11 -I src/ src/Main.cpp src/Managers/FileManager.h src/Managers/FileManager.cpp src/Syncers/Upload.h src/Syncers/Upload.cpp src/Models/Song.h -o build/IcarusDownloadManager diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/src/Main.cpp b/src/Main.cpp new file mode 100644 index 0000000..ed17fb8 --- /dev/null +++ b/src/Main.cpp @@ -0,0 +1,46 @@ +#include +#include + +#include"Syncers/Upload.h" +#include"Managers/FileManager.h" + +using std::cin; +using std::cout; +using std::endl; +using std::string; + +using Managers::FileManager; +using Syncers::Upload; + +string songPath; +string newSongPath; + +int main(int argc, char** argv) +{ + cout<<"Argument size: "< +#include + +#include"FileManager.h" + +using std::cout; +using std::endl; +using std::ifstream; +using std::ofstream; +using std::string; + +namespace Managers +{ + FileManager::FileManager() {} + FileManager::FileManager(string filePath) + { + this->filePath = filePath; + readFile(); + } + + + void FileManager::saveFile(string newFilePath) + { + if (!fileRead) + readFile(); + + ofstream of{newFilePath, ofstream::binary}; + of.write(fileBuffer, fileBufferLength); + of.close(); + } + + void FileManager::readFile() + { + ifstream is{filePath, ifstream::binary}; + if (is) + { + is.seekg (0, is.end); + fileBufferLength = is.tellg(); + is.seekg (0, is.beg); + + fileBuffer = new char [fileBufferLength]; + + cout<< "Reading "<filePath = filePath; + } + + char* FileManager::retrieveFileBuffer() const + { + return fileBuffer; + } +} diff --git a/src/Managers/FileManager.h b/src/Managers/FileManager.h new file mode 100644 index 0000000..8cb9a5f --- /dev/null +++ b/src/Managers/FileManager.h @@ -0,0 +1,28 @@ +#ifndef FILEMANAGER_H_ +#define FILEMANAGER_H_ + +#include + +namespace Managers +{ + class FileManager + { + public: + FileManager(); + FileManager(std::string); + + void saveFile(std::string); + void modifyFilePath(std::string); + + char* retrieveFileBuffer() const; + private: + void readFile(); + + std::string filePath; + char* fileBuffer; + bool fileRead; + int fileBufferLength; + }; +} + +#endif diff --git a/src/Managers/FileManager.h.gch b/src/Managers/FileManager.h.gch new file mode 100644 index 0000000..c72a0f6 Binary files /dev/null and b/src/Managers/FileManager.h.gch differ diff --git a/src/Models/Song.cpp b/src/Models/Song.cpp new file mode 100644 index 0000000..8a92c1d --- /dev/null +++ b/src/Models/Song.cpp @@ -0,0 +1,5 @@ +#include"Song.h" + +namespace Models +{ +} diff --git a/src/Models/Song.h b/src/Models/Song.h new file mode 100644 index 0000000..101f6b2 --- /dev/null +++ b/src/Models/Song.h @@ -0,0 +1,25 @@ +#ifndef SONG_H_ +#define SONG_H_ + +#include + +#include + +using json = nlohmann::json; + +namespace Models +{ + struct Song + { + int id; + std::string title; + std::string artist; + std::string album; + std::string genre; + int year; + int duration; + char* songData; + }; +} + +#endif diff --git a/src/Syncers/Upload.cpp b/src/Syncers/Upload.cpp new file mode 100644 index 0000000..9a920fe --- /dev/null +++ b/src/Syncers/Upload.cpp @@ -0,0 +1,93 @@ +#include +#include + +#include + +#include"Upload.h" + +using std::cout; +using std::endl; +using std::string; + +using json = nlohmann::json; + +namespace Syncers +{ + Upload::Upload() { } + Upload::Upload(string filePath) + { + this->fMgr = Managers::FileManager{filePath}; + } + + + void Upload::uploadSong() + { + configureSong(); + json jObj = serializeObject(); + printJsonData(jObj); + + } + + void Upload::configureSong() + { + int id = 0; + string title = "What of it?"; + string artist = "Kuoth"; + string album = "I"; + string genre = "Untitled"; + int year = 2019; + int duration = 260; + + this->song = Models::Song{}; + this->song.id = id; + this->song.title = title; + this->song.artist = artist; + this->song.album = album; + this->song.genre = genre; + this->song.year = year; + this->song.duration = duration; + this->song.songData = fMgr.retrieveFileBuffer(); + cout<<*song.songData< + +#include + +#include"Managers/FileManager.h" +#include"Models/Song.h" + + +namespace Syncers +{ + class Upload + { + public: + Upload(); + Upload(std::string); + + void uploadSong(); + + private: + Managers::FileManager fMgr; + Models::Song song; + std::string apiUrl{"http://192.168.1.24"}; + std::string apiEndPoint{"/api/song"}; + int port{9349}; + + void configureSong(); + void printSongDetails(); + void printJsonData(nlohmann::json); + + nlohmann::json serializeObject(); + }; +} + +#endif diff --git a/src/Syncers/Upload.h.gch b/src/Syncers/Upload.h.gch new file mode 100644 index 0000000..eabcbc9 Binary files /dev/null and b/src/Syncers/Upload.h.gch differ diff --git a/src/split Upload.cpp b/src/split Upload.cpp new file mode 100644 index 0000000..8d6cbd9 --- /dev/null +++ b/src/split Upload.cpp @@ -0,0 +1,5 @@ +#include"Upload.h" + +Upload::Upload() +{ +}