| 1986 | } |
| 1987 | |
| 1988 | int RenameFileEntry( |
| 1989 | TMPQArchive * ha, |
| 1990 | TMPQFile * hf, |
| 1991 | const char * szNewFileName) |
| 1992 | { |
| 1993 | TFileEntry * pFileEntry = hf->pFileEntry; |
| 1994 | TMPQHash * pHashEntry = hf->pHashEntry; |
| 1995 | LCID lcLocale = 0; |
| 1996 | |
| 1997 | // If the archive hash hash table, we need to free the hash table entry |
| 1998 | if(ha->pHashTable != NULL) |
| 1999 | { |
| 2000 | // The file must have hash table entry assigned |
| 2001 | // Will exit if there are multiple HASH entries pointing to the same file entry |
| 2002 | if(pHashEntry == NULL) |
| 2003 | return ERROR_NOT_SUPPORTED; |
| 2004 | |
| 2005 | // Save the locale |
| 2006 | lcLocale = pHashEntry->lcLocale; |
| 2007 | |
| 2008 | // Mark the hash table entry as deleted |
| 2009 | pHashEntry->dwName1 = 0xFFFFFFFF; |
| 2010 | pHashEntry->dwName2 = 0xFFFFFFFF; |
| 2011 | pHashEntry->lcLocale = 0xFFFF; |
| 2012 | pHashEntry->Platform = 0xFF; |
| 2013 | pHashEntry->Reserved = 0xFF; |
| 2014 | pHashEntry->dwBlockIndex = HASH_ENTRY_DELETED; |
| 2015 | } |
| 2016 | |
| 2017 | // Free the old file name |
| 2018 | if(pFileEntry->szFileName != NULL) |
| 2019 | STORM_FREE(pFileEntry->szFileName); |
| 2020 | pFileEntry->szFileName = NULL; |
| 2021 | |
| 2022 | // Allocate new file name |
| 2023 | AllocateFileName(ha, pFileEntry, szNewFileName); |
| 2024 | |
| 2025 | // Allocate new hash entry |
| 2026 | if(ha->pHashTable != NULL) |
| 2027 | { |
| 2028 | // Since we freed one hash entry before, this must succeed |
| 2029 | hf->pHashEntry = AllocateHashEntry(ha, pFileEntry, lcLocale); |
| 2030 | assert(hf->pHashEntry != NULL); |
| 2031 | } |
| 2032 | |
| 2033 | return ERROR_SUCCESS; |
| 2034 | } |
| 2035 | |
| 2036 | int DeleteFileEntry(TMPQArchive * ha, TMPQFile * hf) |
| 2037 | { |
nothing calls this directly
no test coverage detected