mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-02 07:45:26 +00:00
Working Mod Sync
This commit is contained in:
parent
9a47f651fc
commit
d50f205787
@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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(),'\\','/');
|
||||
}
|
@ -12,3 +12,4 @@ extern std::string Resource;
|
||||
extern std::string ServerVersion;
|
||||
extern std::string ClientVersion;
|
||||
extern std::string FileList;
|
||||
extern std::string FileSizes;
|
||||
|
Loading…
x
Reference in New Issue
Block a user