mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2025-12-05 11:44:53 +01:00
Implemented some ugc remote storage functions related to fileshare.
This commit is contained in:
parent
42fd868099
commit
26c5b7949f
4 changed files with 56 additions and 15 deletions
|
|
@ -537,22 +537,19 @@ int Local_Storage::store_data_settings(std::string file, char *data, unsigned in
|
|||
return store_file_data(get_global_settings_path(), file, data, length);
|
||||
}
|
||||
|
||||
int Local_Storage::get_file_data(std::string full_path, char *data, unsigned int max_length)
|
||||
int Local_Storage::get_file_data(std::string full_path, char *data, unsigned int max_length, unsigned int offset)
|
||||
{
|
||||
std::ifstream myfile;
|
||||
myfile.open(full_path, std::ios::binary | std::ios::in);
|
||||
if (!myfile.is_open()) return -1;
|
||||
|
||||
std::streampos size = myfile.tellg();
|
||||
myfile.seekg (0, std::ios::beg);
|
||||
if (size > max_length) max_length = size;
|
||||
|
||||
myfile.seekg (offset, std::ios::beg);
|
||||
myfile.read (data, max_length);
|
||||
myfile.close();
|
||||
return myfile.gcount();
|
||||
}
|
||||
|
||||
int Local_Storage::get_data(std::string folder, std::string file, char *data, unsigned int max_length)
|
||||
int Local_Storage::get_data(std::string folder, std::string file, char *data, unsigned int max_length, unsigned int offset)
|
||||
{
|
||||
file = sanitize_file_name(file);
|
||||
if (folder.back() != *PATH_SEPARATOR) {
|
||||
|
|
@ -560,7 +557,7 @@ int Local_Storage::get_data(std::string folder, std::string file, char *data, un
|
|||
}
|
||||
|
||||
std::string full_path = save_directory + appid + folder + file;
|
||||
return get_file_data(full_path, data, max_length);
|
||||
return get_file_data(full_path, data, max_length, offset);
|
||||
}
|
||||
|
||||
int Local_Storage::get_data_settings(std::string file, char *data, unsigned int max_length)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue