Working Mod Sync

This commit is contained in:
Anonymous275 2020-04-14 01:01:06 +03:00
parent 9a47f651fc
commit d50f205787
3 changed files with 18 additions and 6 deletions

View File

@ -16,7 +16,8 @@ int ParseAndSend(SOCKET Client, std::string Data){
bool FileSent = true;
switch (ID){
case 'a' :
Response = FileList;
Response = FileList+FileSizes;
if(Response.empty())Response = " ";
break;
case 'b' :
FileSent = false;
@ -35,9 +36,10 @@ int ParseAndSend(SOCKET Client, std::string Data){
f.seekg(0, std::ios_base::beg);
f.read(&Response[0], Size);
f.close();
}else{f.close();}
}else f.close();
if(DataSent != Size){
Packet.clear();
if((Size-DataSent) < 65535){
Packet = Response.substr(Prev,(Size-DataSent));
DataSent += (Size-DataSent);
@ -48,14 +50,15 @@ int ParseAndSend(SOCKET Client, std::string Data){
}
Prev = DataSent;
}else{
Size = DataSent = Prev = 0;
Response = "End of file";
Size = 0;
DataSent = 0;
Prev = 0;
FileSent = true;
Packet.clear();
}
}else{
FileSent = true;
Response = "Cannot Open File " + FLocation;
Response = "Cannot Open";
}
}

View File

@ -2,6 +2,7 @@
/// Created by Anonymous275 on 4/11/2020
///
#include <fstream>
#include <iostream>
#include <algorithm>
#include <filesystem>
@ -9,6 +10,7 @@
namespace fs = std::experimental::filesystem;
std::string FileList;
std::string FileSizes;
void HandleResources(const std::string& path){
struct stat info{};
@ -16,7 +18,13 @@ void HandleResources(const std::string& path){
_wmkdir(L"Resources");
}
for (const auto & entry : fs::directory_iterator(path)){
FileList += entry.path().string() + ";";
int pos = entry.path().string().find(".zip");
if(pos != std::string::npos){
if(entry.path().string().length() - pos == 4){
FileList += entry.path().string() + ";";
FileSizes += std::to_string(fs::file_size(entry.path()))+";";
}
}
}
std::replace(FileList.begin(),FileList.end(),'\\','/');
}

View File

@ -12,3 +12,4 @@ extern std::string Resource;
extern std::string ServerVersion;
extern std::string ClientVersion;
extern std::string FileList;
extern std::string FileSizes;