summaryrefslogtreecommitdiff
path: root/src/SFileAddFile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/SFileAddFile.cpp')
-rw-r--r--src/SFileAddFile.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/SFileAddFile.cpp b/src/SFileAddFile.cpp
index 59a245a..775a969 100644
--- a/src/SFileAddFile.cpp
+++ b/src/SFileAddFile.cpp
@@ -386,7 +386,7 @@ int SFileAddFile_Init(
if(nError == ERROR_SUCCESS)
{
// Find the position where the file will be stored
- FindFreeMpqSpace(ha, &hf->MpqFilePos);
+ hf->MpqFilePos = FindFreeMpqSpace(ha);
hf->RawFilePos = ha->MpqPos + hf->MpqFilePos;
hf->bIsWriteHandle = true;
@@ -418,15 +418,19 @@ int SFileAddFile_Init(
}
else
{
- // If the file exists and "replace existing" is not set, fail it
- if((dwFlags & MPQ_FILE_REPLACEEXISTING) == 0)
- nError = ERROR_ALREADY_EXISTS;
-
- // If the file entry already contains a file
- // and it is a pseudo-name, replace it
- if(nError == ERROR_SUCCESS)
+ // Only if the file really exists
+ if(pFileEntry->dwFlags & MPQ_FILE_EXISTS)
{
- AllocateFileName(pFileEntry, szFileName);
+ // If the file exists and "replace existing" is not set, fail it
+ if((dwFlags & MPQ_FILE_REPLACEEXISTING) == 0)
+ nError = ERROR_ALREADY_EXISTS;
+
+ // If the file entry already contains a file
+ // and it is a pseudo-name, replace it
+ if(nError == ERROR_SUCCESS)
+ {
+ AllocateFileName(pFileEntry, szFileName);
+ }
}
}
}