1
0
Fork 0
mirror of https://gitlab.com/Mr_Goldberg/goldberg_emulator.git synced 2024-11-14 10:50:13 +01:00

Merge branch 'Nemirtingas/goldberg_emulator-issue_#14'

This commit is contained in:
Mr_Goldberg 2019-07-12 11:25:22 -04:00
commit ba1591d8e7
No known key found for this signature in database
GPG key ID: 8597D87419DEF278
3 changed files with 26 additions and 6 deletions

View file

@ -93,6 +93,7 @@ struct Steam_Call_Result {
Steam_Call_Result(SteamAPICall_t a, int icb, void *r, unsigned int s, double r_in, bool run_cc_cb) { Steam_Call_Result(SteamAPICall_t a, int icb, void *r, unsigned int s, double r_in, bool run_cc_cb) {
api_call = a; api_call = a;
result.resize(s); result.resize(s);
if (s > 0 && r != NULL)
memcpy(&(result[0]), r, s); memcpy(&(result[0]), r, s);
created = std::chrono::high_resolution_clock::now(); created = std::chrono::high_resolution_clock::now();
run_in = r_in; run_in = r_in;

View file

@ -192,6 +192,8 @@ static std::vector<struct File_Data> get_filenames(std::string strPath)
static std::vector<struct File_Data> get_filenames_recursive(std::string base_path) static std::vector<struct File_Data> get_filenames_recursive(std::string base_path)
{ {
if (base_path.back() == *PATH_SEPARATOR)
base_path.pop_back();
std::vector<struct File_Data> output; std::vector<struct File_Data> output;
std::string strPath = base_path; std::string strPath = base_path;
strPath = strPath.append("\\*"); strPath = strPath.append("\\*");
@ -211,11 +213,12 @@ static std::vector<struct File_Data> get_filenames_recursive(std::string base_pa
std::string dir_name = ffd.cFileName; std::string dir_name = ffd.cFileName;
std::string path = base_path; std::string path = base_path;
path += "\\"; path += PATH_SEPARATOR;
path += dir_name; path += dir_name;
std::vector<struct File_Data> lower = get_filenames_recursive(path); std::vector<struct File_Data> lower = get_filenames_recursive(path);
std::transform(lower.begin(), lower.end(), std::back_inserter(output), [dir_name](File_Data f) {f.name = dir_name + "\\" + f.name; return f;}); output.push_back(File_Data{ dir_name });// Is this needed ? Add folder name to the list of files ?
std::transform(lower.begin(), lower.end(), std::back_inserter(output), [&dir_name](File_Data f) {f.name = dir_name + "\\" + f.name; return f;});
} else { } else {
File_Data f; File_Data f;
f.name = ffd.cFileName; f.name = ffd.cFileName;
@ -354,7 +357,8 @@ static std::vector<struct File_Data> get_filenames_recursive(std::string base_pa
path += dir_name; path += dir_name;
std::vector<struct File_Data> lower = get_filenames_recursive(path); std::vector<struct File_Data> lower = get_filenames_recursive(path);
std::transform(lower.begin(), lower.end(), std::back_inserter(output), [dir_name](File_Data f) {f.name = dir_name + "/" + f.name; return f;}); output.push_back(File_Data{ dir_name });// Is this needed ? Add folder name to the list of files ?
std::transform(lower.begin(), lower.end(), std::back_inserter(output), [&dir_name](File_Data f) {f.name = dir_name + "/" + f.name; return f;});
} }
} }
} }
@ -584,7 +588,19 @@ bool Local_Storage::file_exists(std::string folder, std::string file)
std::string full_path = save_directory + appid + folder + file; std::string full_path = save_directory + appid + folder + file;
struct stat buffer; struct stat buffer;
return (stat (full_path.c_str(), &buffer) == 0);
if (stat(full_path.c_str(), &buffer) != 0)
return false;
#if defined(STEAM_WIN32)
if ( buffer.st_mode & _S_IFDIR)
return false;
#else
if (S_ISDIR(buffer.st_mode))
return false;
#endif
return true;
} }
unsigned int Local_Storage::file_size(std::string folder, std::string file) unsigned int Local_Storage::file_size(std::string folder, std::string file)

View file

@ -379,7 +379,10 @@ unsigned int receive_buffer_amount(sock_t sock)
static void send_tcp_pending(struct TCP_Socket &socket) static void send_tcp_pending(struct TCP_Socket &socket)
{ {
int len = send(socket.sock, &(socket.send_buffer[0]), socket.send_buffer.size(), MSG_NOSIGNAL); size_t buf_size = socket.send_buffer.size();
if (buf_size == 0) return;
int len = send(socket.sock, &(socket.send_buffer[0]), buf_size, MSG_NOSIGNAL);
if (len <= 0) return; if (len <= 0) return;
socket.send_buffer.erase(socket.send_buffer.begin(), socket.send_buffer.begin() + len); socket.send_buffer.erase(socket.send_buffer.begin(), socket.send_buffer.begin() + len);