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
+8 -5
View File
@@ -16,7 +16,8 @@ int ParseAndSend(SOCKET Client, std::string Data){
bool FileSent = true; bool FileSent = true;
switch (ID){ switch (ID){
case 'a' : case 'a' :
Response = FileList; Response = FileList+FileSizes;
if(Response.empty())Response = " ";
break; break;
case 'b' : case 'b' :
FileSent = false; FileSent = false;
@@ -35,9 +36,10 @@ int ParseAndSend(SOCKET Client, std::string Data){
f.seekg(0, std::ios_base::beg); f.seekg(0, std::ios_base::beg);
f.read(&Response[0], Size); f.read(&Response[0], Size);
f.close(); f.close();
}else{f.close();} }else f.close();
if(DataSent != Size){ if(DataSent != Size){
Packet.clear();
if((Size-DataSent) < 65535){ if((Size-DataSent) < 65535){
Packet = Response.substr(Prev,(Size-DataSent)); Packet = Response.substr(Prev,(Size-DataSent));
DataSent += (Size-DataSent); DataSent += (Size-DataSent);
@@ -48,14 +50,15 @@ int ParseAndSend(SOCKET Client, std::string Data){
} }
Prev = DataSent; Prev = DataSent;
}else{ }else{
Size = DataSent = Prev = 0; Size = 0;
Response = "End of file"; DataSent = 0;
Prev = 0;
FileSent = true; FileSent = true;
Packet.clear(); Packet.clear();
} }
}else{ }else{
FileSent = true; FileSent = true;
Response = "Cannot Open File " + FLocation; Response = "Cannot Open";
} }
} }
+9 -1
View File
@@ -2,6 +2,7 @@
/// Created by Anonymous275 on 4/11/2020 /// Created by Anonymous275 on 4/11/2020
/// ///
#include <fstream>
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
#include <filesystem> #include <filesystem>
@@ -9,6 +10,7 @@
namespace fs = std::experimental::filesystem; namespace fs = std::experimental::filesystem;
std::string FileList; std::string FileList;
std::string FileSizes;
void HandleResources(const std::string& path){ void HandleResources(const std::string& path){
struct stat info{}; struct stat info{};
@@ -16,7 +18,13 @@ void HandleResources(const std::string& path){
_wmkdir(L"Resources"); _wmkdir(L"Resources");
} }
for (const auto & entry : fs::directory_iterator(path)){ 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(),'\\','/'); std::replace(FileList.begin(),FileList.end(),'\\','/');
} }
+1
View File
@@ -12,3 +12,4 @@ extern std::string Resource;
extern std::string ServerVersion; extern std::string ServerVersion;
extern std::string ClientVersion; extern std::string ClientVersion;
extern std::string FileList; extern std::string FileList;
extern std::string FileSizes;