Skip to content

Commit

Permalink
v0.0.7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Helmssyss committed Dec 14, 2023
1 parent c55fd53 commit 1c2e1b4
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 14,969 deletions.
3 changes: 1 addition & 2 deletions CLI/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <iostream>

#include "./src/Public/server.h"
#include <iostream>

int main(int argc, char* *argv) {
Server* server = new Server();
Expand Down
30 changes: 13 additions & 17 deletions CLI/src/Private/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void Server::Start() {
const std::wstring wInputFilePath(input_file.begin(), input_file.end());
const wchar_t* wInputFile = wInputFilePath.c_str();
if (FileExists(wInputFile)) {
SendClientFile(input_file, buffer, bufferSize);
SendClientFile(input_file.c_str(), buffer, bufferSize);
fileIsExists = true;

}else if (input_file == "n" || input_file == "N") {
Expand Down Expand Up @@ -118,22 +118,22 @@ std::string Server::GetClientDeviceName(char* buffer, int& buffSize) {
return resultData;
}

void Server::SendClientFile(std::string& inputFile, char* buffer, const int& bufferSize) {
short fileNameCount = 0;
void Server::SendClientFile(const char *inputFile, char* buffer, const int& bufferSize) {
std::ifstream file(inputFile, std::ios::binary);
file.seekg(0, std::ios::end);
const unsigned long fileSize = file.tellg();
file.close();

std::vector<std::string> str = FileMessageParse(inputFile, fileNameCount, '/');
std::string firstFileContent;
const std::string seperator = "|:FILE:|";
firstFileContent = seperator + str[fileNameCount] + seperator + std::to_string(fileSize) + seperator;
Sleep(10);
send(ClientSocket, firstFileContent.c_str(), strlen(firstFileContent.c_str()), 0);
short fileNameCount = 0;
const std::vector<std::string> parsedFileName = FileMessageParse(inputFile, fileNameCount, '\\');
const std::string seperator = "|:MAGNET:|";
const std::string sendDataPart = seperator + parsedFileName[fileNameCount] + seperator + std::to_string(fileSize) + seperator;

if(fileSize < 100000) Sleep(1000);
else Sleep(10);
send(ClientSocket, sendDataPart.c_str(), strlen(sendDataPart.c_str()), 0);
Sleep(10);
send(ClientSocket, S_FILE_CAME, strlen(S_FILE_CAME), 0);
Sleep(10);

bool run = true;
while (run) {
Expand Down Expand Up @@ -167,7 +167,6 @@ void Server::SendClientFile(std::string& inputFile, char* buffer, const int& buf
console::CompleteUploadFileDisplay(fileSize);
Sleep(10);
send(ClientSocket, FILE_SEND_END, strlen(FILE_SEND_END), 0);
// memset(buffer, 0, sizeof(buffer));
}

void Server::HandleFileProcess(char* &buffer, int &bufferSize, bool saveMultipleFile) {
Expand Down Expand Up @@ -204,7 +203,6 @@ void Server::HandleFileProcess(char* &buffer, int &bufferSize, bool saveMultiple
send(ClientSocket, DECLINE, strlen(DECLINE), 0);
console::AlertMessage("Ignored");
isAccepted = true;
memset(buffer, 0, sizeof(buffer));
}
}
}
Expand Down Expand Up @@ -266,14 +264,12 @@ std::vector<std::string> Server::FileMessageParse(std::string message, short& ms
std::stringstream sstream;
std::string temp;
std::vector<std::string> resultVector;
int count = 0;
short count = 0;
sstream << message;

for (char i : message) {
if (i == seperator) {
for (char i : message)
if (i == seperator)
count++;
}
}

for (int i = 0; i <= count; i++) {
std::getline(sstream, temp, seperator);
Expand Down
2 changes: 1 addition & 1 deletion CLI/src/Public/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Server {
void CreateSaveFilePathFolder() const;
void HandleFileProcess(char*& buffer, int& bufferSize, bool saveMultipleFile = false);
void HandleFileTransfer(char* buffer, int& bufferSize);
void SendClientFile(string& inputFolder, char* buffer, const int& bufferSize);
void SendClientFile(const char *inputFile, char* buffer, const int& bufferSize);
void SaveFileData(const int& bufferSize, const char* fileName);
bool FolderExists(const wchar_t* folderPath) const;
bool FileExists(const wchar_t* filePath) const;
Expand Down
File renamed without changes.
77 changes: 0 additions & 77 deletions GUI/src/service/src/3rdParty/XMLib/pugiconfig.hpp

This file was deleted.

Loading

0 comments on commit 1c2e1b4

Please sign in to comment.