Lots of defect fixes

This commit is contained in:
Raul Tambre 2015-10-17 20:47:18 +03:00
parent 5dfc22a604
commit fac9d74344
21 changed files with 341 additions and 95 deletions

View file

@ -327,7 +327,13 @@ int OSCopyFile(const char* source, const char* destination, bool overwrite)
//sendfile will work with non-socket output (i.e. regular file) on Linux 2.6.33+
off_t bytesCopied = 0;
struct stat fileinfo = { 0 };
fstat(input, &fileinfo);
s32 ret = fstat(input, &fileinfo);
if (ret < 0)
{
return -1;
}
int result = sendfile(output, input, &bytesCopied, fileinfo.st_size) == -1 ? -1 : 0;
#endif

View file

@ -1,4 +1,5 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "VirtualMemory.h"
#ifdef _WIN32
#include <Windows.h>
@ -21,13 +22,23 @@ namespace memory_helper
#endif
}
void commit_page_memory(void* pointer, size_t page_size)
s32 commit_page_memory(void* pointer, size_t page_size)
{
#ifdef _WIN32
VirtualAlloc((u8*)pointer, page_size, MEM_COMMIT, PAGE_READWRITE);
if (VirtualAlloc((u8*)pointer, page_size, MEM_COMMIT, PAGE_READWRITE) == NULL)
{
LOG_ERROR(HLE, "commit_page_memory VirtualAlloc failed.");
return -1;
}
#else
mprotect((u8*)pointer, page_size, PROT_READ | PROT_WRITE);
s32 ret = mprotect((u8*)pointer, page_size, PROT_READ | PROT_WRITE)
if (ret < 0)
{
LOG_ERROR(HLE, "commit_page_memory mprotect failed. (%d)", ret);
return -1;
}
#endif
return 0;
}
void free_reserved_memory(void* pointer, size_t size)

View file

@ -12,8 +12,11 @@ namespace memory_helper
* Commit page_size bytes of virtual memory starting at pointer.
* That is, bake reserved memory with physical memory.
* pointer should belong to a range of reserved memory.
*
* Returns 0, if was successful.
* Returns -1, if was unsuccessful.
*/
void commit_page_memory(void* pointer, size_t page_size);
s32 commit_page_memory(void* pointer, size_t page_size);
/**
* Free memory alloced via reserve_memory.

View file

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "restore_new.h"
#include "Utilities/Log.h"
#pragma warning(push)
#pragma message("TODO: remove wx dependency: <wx/image.h>")
#pragma warning(disable : 4996)
@ -42,7 +43,8 @@ void rImage::SaveFile(const std::string& name, rImageType type)
std::string rPlatform::getConfigDir()
{
static std::string dir = ".";
if (dir == ".") {
if (dir == ".")
{
#ifdef _WIN32
dir = "";
//mkdir(dir.c_str());
@ -54,7 +56,16 @@ std::string rPlatform::getConfigDir()
else // Just in case
dir = "./config";
dir = dir + "/rpcs3/";
mkdir(dir.c_str(), 0777);
s32 ret = mkdir(dir.c_str(), 0777)
if (ret == EEXIST)
{
LOG_WARNING(HLE, "Configuration directory already exists. (%s)", dir);
}
else if (ret < 0)
{
LOG_ERROR(HLE, "An error occured during the creation of the configuration directory. (%d)", ret);
}
#endif
}
return dir;