fixed bug #1542530 - WriteUninstaller fails to overwrite read-only uninstallers
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4822 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
9f37ece536
commit
a92506d828
3 changed files with 12 additions and 4 deletions
|
@ -455,8 +455,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
||||||
// remove read only flag if overwrite mode is on
|
// remove read only flag if overwrite mode is on
|
||||||
if (!overwriteflag)
|
if (!overwriteflag)
|
||||||
{
|
{
|
||||||
int attr=GetFileAttributes(buf0);
|
remove_ro_attr(buf0);
|
||||||
SetFileAttributes(buf0,attr&(~FILE_ATTRIBUTE_READONLY));
|
|
||||||
}
|
}
|
||||||
hOut=myOpenFile(buf0,GENERIC_WRITE,(overwriteflag==1)?CREATE_NEW:CREATE_ALWAYS);
|
hOut=myOpenFile(buf0,GENERIC_WRITE,(overwriteflag==1)?CREATE_NEW:CREATE_ALWAYS);
|
||||||
if (hOut == INVALID_HANDLE_VALUE)
|
if (hOut == INVALID_HANDLE_VALUE)
|
||||||
|
@ -1445,6 +1444,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
||||||
}
|
}
|
||||||
validate_filename(buf1);
|
validate_filename(buf1);
|
||||||
|
|
||||||
|
remove_ro_attr(buf1);
|
||||||
hFile=myOpenFile(buf1,GENERIC_WRITE,CREATE_ALWAYS);
|
hFile=myOpenFile(buf1,GENERIC_WRITE,CREATE_ALWAYS);
|
||||||
if (hFile != INVALID_HANDLE_VALUE)
|
if (hFile != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
|
|
|
@ -165,7 +165,7 @@ void NSISCALL myDelete(char *buf, int flags)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log_printf2("Delete: DeleteFile(\"%s\")",buf);
|
log_printf2("Delete: DeleteFile(\"%s\")",buf);
|
||||||
SetFileAttributes(buf,fd.dwFileAttributes&(~FILE_ATTRIBUTE_READONLY));
|
remove_ro_attr(buf);
|
||||||
if (!DeleteFile(buf))
|
if (!DeleteFile(buf))
|
||||||
{
|
{
|
||||||
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
||||||
|
@ -208,7 +208,7 @@ void NSISCALL myDelete(char *buf, int flags)
|
||||||
{
|
{
|
||||||
addtrailingslash(buf);
|
addtrailingslash(buf);
|
||||||
log_printf2("RMDir: RemoveDirectory(\"%s\")",buf);
|
log_printf2("RMDir: RemoveDirectory(\"%s\")",buf);
|
||||||
SetFileAttributes(buf,FILE_ATTRIBUTE_NORMAL);
|
remove_ro_attr(buf);
|
||||||
if (!RemoveDirectory(buf))
|
if (!RemoveDirectory(buf))
|
||||||
{
|
{
|
||||||
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
||||||
|
@ -370,6 +370,13 @@ void NSISCALL mini_memcpy(void *out, const void *in, int len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NSISCALL remove_ro_attr(char *file)
|
||||||
|
{
|
||||||
|
int attr = GetFileAttributes(file);
|
||||||
|
if (attr != INVALID_FILE_ATTRIBUTES)
|
||||||
|
SetFileAttributes(file,attr&(~FILE_ATTRIBUTE_READONLY));
|
||||||
|
}
|
||||||
|
|
||||||
HANDLE NSISCALL myOpenFile(const char *fn, DWORD da, DWORD cd)
|
HANDLE NSISCALL myOpenFile(const char *fn, DWORD da, DWORD cd)
|
||||||
{
|
{
|
||||||
int attr = GetFileAttributes(fn);
|
int attr = GetFileAttributes(fn);
|
||||||
|
|
|
@ -90,6 +90,7 @@ int NSISCALL is_valid_instpath(char *s);
|
||||||
void NSISCALL validate_filename(char *fn);
|
void NSISCALL validate_filename(char *fn);
|
||||||
void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew);
|
void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew);
|
||||||
void NSISCALL mini_memcpy(void *out, const void *in, int len);
|
void NSISCALL mini_memcpy(void *out, const void *in, int len);
|
||||||
|
void NSISCALL remove_ro_attr(char *file);
|
||||||
|
|
||||||
void * NSISCALL myGetProcAddress(char *dll, char *func);
|
void * NSISCALL myGetProcAddress(char *dll, char *func);
|
||||||
void NSISCALL MessageLoop(UINT uCheckedMsg);
|
void NSISCALL MessageLoop(UINT uCheckedMsg);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue