Minor changes on FOPENTEXT
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6077 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
2170215b06
commit
b431c21048
5 changed files with 14 additions and 35 deletions
|
@ -16,31 +16,9 @@
|
|||
|
||||
#include "tstring.h"
|
||||
#include "validateunicode.h"
|
||||
#include "util.h"
|
||||
#include <vector>
|
||||
|
||||
// Simple RAII for C-styled FILE pointers.
|
||||
class ScopedFile
|
||||
{
|
||||
public:
|
||||
ScopedFile(FILE* file) : m_file(file) {}
|
||||
|
||||
~ScopedFile()
|
||||
{
|
||||
if (this->m_file != NULL)
|
||||
{
|
||||
fflush(this->m_file);
|
||||
fclose(this->m_file);
|
||||
}
|
||||
}
|
||||
|
||||
operator FILE*(){ return this->m_file; }
|
||||
|
||||
operator bool() { return this->m_file != NULL; }
|
||||
|
||||
private:
|
||||
FILE* m_file;
|
||||
};
|
||||
|
||||
FILE* FileOpenUnicodeText(const TCHAR* file, const TCHAR* mode)
|
||||
{
|
||||
extern FILE *g_output;
|
||||
|
@ -51,10 +29,11 @@ FILE* FileOpenUnicodeText(const TCHAR* file, const TCHAR* mode)
|
|||
if (_tcsstr(mode, _T("w+")) ||
|
||||
_tcsstr(mode, _T("r")))
|
||||
{
|
||||
ScopedFile fp(_tfopen(file, _T("rb")));
|
||||
FILE* fp = _tfopen(file, _T("rb"));
|
||||
|
||||
if (fp)
|
||||
{
|
||||
MANAGE_WITH(fp, fclose);
|
||||
fseek(fp, 0, SEEK_END);
|
||||
size_t fileSize = ftell(fp);
|
||||
if (fileSize == 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue