Alternative solution to #14

This commit is contained in:
Alcaro 2018-09-17 04:18:38 +02:00
parent 34b6bd8f6b
commit dad6aff01e
2 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,6 @@
//Module name: Floating IPS, Windows frontend
//Author: Alcaro
//Date: June 18, 2015
//Date: See Git history
//Licence: GPL v3.0 or higher
#include "flips.h"
@ -75,6 +75,8 @@ filewrite* filewrite::create(LPCWSTR filename) { return filewrite_w32::create(fi
//TODO: implement properly
//also ensure input==output works if implementing this, rather than getting a file sharing violation
//applies even when selecting multiple patches, of which one overwrites input
filemap* filemap::create(LPCWSTR filename) { return filemap::create_fallback(filename); }

View File

@ -102,7 +102,6 @@ filewrite* filewrite::create_libc(const char * filename) { return filewrite_libc
class filemap_fallback : public filemap {
public:
file* m_f;
size_t m_len;
uint8_t* m_ptr;
@ -120,8 +119,10 @@ public:
size_t len() { return m_len; }
const uint8_t * ptr() { return m_ptr; }
filemap_fallback(file* f, size_t len, uint8_t* ptr) : m_f(f), m_len(len), m_ptr(ptr) {}
~filemap_fallback() { free(m_ptr); delete m_f; }
//delete the file early, to avoid file sharing issues on Windows (and because keeping it is useless)
// https://github.com/Alcaro/Flips/pull/14
filemap_fallback(file* f, size_t len, uint8_t* ptr) : m_len(len), m_ptr(ptr) { delete f; }
~filemap_fallback() { free(m_ptr); }
};
filemap* filemap::create_fallback(LPCWSTR filename)
{