mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2024-12-24 11:48:34 +01:00
Added check on directory in Local_Storage::file_exists
Added check on directory in Local_Storage::file_exists. Added check in get_filenames_recursive if last char is the path separator (some use cases were adding a path separator even if there were already one). In base.h, added check on s and r, that will avoid an out-of-range vector exception on Visual Studio, same for network.cpp.
This commit is contained in:
parent
b093ca90d3
commit
e54072918f
3 changed files with 15 additions and 4 deletions
|
@ -93,7 +93,8 @@ struct Steam_Call_Result {
|
|||
Steam_Call_Result(SteamAPICall_t a, int icb, void *r, unsigned int s, double r_in, bool run_cc_cb) {
|
||||
api_call = a;
|
||||
result.resize(s);
|
||||
memcpy(&(result[0]), r, s);
|
||||
if (s > 0 && r != NULL)
|
||||
memcpy(&(result[0]), r, s);
|
||||
created = std::chrono::high_resolution_clock::now();
|
||||
run_in = r_in;
|
||||
run_call_completed_cb = run_cc_cb;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
if (base_path.back() == *PATH_SEPARATOR)
|
||||
base_path.pop_back();
|
||||
std::vector<struct File_Data> output;
|
||||
std::string strPath = base_path;
|
||||
strPath = strPath.append("\\*");
|
||||
|
@ -211,10 +213,11 @@ static std::vector<struct File_Data> get_filenames_recursive(std::string base_pa
|
|||
std::string dir_name = ffd.cFileName;
|
||||
|
||||
std::string path = base_path;
|
||||
path += "\\";
|
||||
path += PATH_SEPARATOR;
|
||||
path += dir_name;
|
||||
|
||||
std::vector<struct File_Data> lower = get_filenames_recursive(path);
|
||||
// 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 {
|
||||
File_Data f;
|
||||
|
@ -584,6 +587,10 @@ bool Local_Storage::file_exists(std::string folder, std::string file)
|
|||
|
||||
std::string full_path = save_directory + appid + folder + file;
|
||||
struct stat buffer;
|
||||
|
||||
if (GetFileAttributes(full_path.c_str()) & FILE_ATTRIBUTE_DIRECTORY)
|
||||
return false;
|
||||
|
||||
return (stat (full_path.c_str(), &buffer) == 0);
|
||||
}
|
||||
|
||||
|
@ -636,7 +643,7 @@ bool Local_Storage::iterate_file(std::string folder, int index, char *output_fil
|
|||
std::string name = desanitize_file_name(files[index].name);
|
||||
if (output_size) *output_size = file_size(folder, name);
|
||||
#if defined(STEAM_WIN32)
|
||||
name = replace_with(name, "/", PATH_SEPARATOR);
|
||||
name = replace_with(name, PATH_SEPARATOR, "/");
|
||||
#endif
|
||||
strcpy(output_filename, name.c_str());
|
||||
return true;
|
||||
|
|
|
@ -379,7 +379,10 @@ unsigned int receive_buffer_amount(sock_t sock)
|
|||
|
||||
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;
|
||||
|
||||
socket.send_buffer.erase(socket.send_buffer.begin(), socket.send_buffer.begin() + len);
|
||||
|
|
Loading…
Reference in a new issue