From 99de80e7224f2491fb7518e32f195ad6a912b624 Mon Sep 17 00:00:00 2001 From: Tannin Date: Fri, 28 Nov 2014 11:19:20 +0100 Subject: replaced all uses of NULL with nullptr fixed a few placed where NULL was used as a number or boolean --- src/shared/directoryentry.cpp | 56 +++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'src/shared/directoryentry.cpp') diff --git a/src/shared/directoryentry.cpp b/src/shared/directoryentry.cpp index 0adf0812..58bf5ae6 100644 --- a/src/shared/directoryentry.cpp +++ b/src/shared/directoryentry.cpp @@ -232,8 +232,8 @@ std::vector FilesOrigin::getFiles() const void FileEntry::addOrigin(int origin, FILETIME fileTime, const std::wstring &archive) { - m_LastAccessed = time(NULL); - if (m_Parent != NULL) { + m_LastAccessed = time(nullptr); + if (m_Parent != nullptr) { m_Parent->propagateOrigin(origin); } if (m_Origin == -1) { @@ -290,8 +290,8 @@ bool FileEntry::removeOrigin(int origin) // now we need to update the file time... std::wstring filePath = getFullPath(); HANDLE file = ::CreateFile(filePath.c_str(), GENERIC_READ | GENERIC_WRITE, - 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (!::GetFileTime(file, NULL, NULL, &m_FileTime)) { + 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); + if (!::GetFileTime(file, nullptr, nullptr, &m_FileTime)) { // maybe this file is in a bsa, but there is no easy way to find out which. User should refresh // the view to find out m_Archive = L"bsa?"; @@ -324,13 +324,13 @@ static bool ByOriginPriority(DirectoryEntry *entry, int LHS, int RHS) FileEntry::FileEntry() - : m_Index(UINT_MAX), m_Name(), m_Origin(-1), m_Parent(NULL), m_LastAccessed(time(NULL)) + : m_Index(UINT_MAX), m_Name(), m_Origin(-1), m_Parent(nullptr), m_LastAccessed(time(nullptr)) { LEAK_TRACE; } FileEntry::FileEntry(Index index, const std::wstring &name, DirectoryEntry *parent) - : m_Index(index), m_Name(name), m_Origin(-1), m_Parent(parent), m_Archive(L""), m_LastAccessed(time(NULL)) + : m_Index(index), m_Name(name), m_Origin(-1), m_Parent(parent), m_Archive(L""), m_LastAccessed(time(nullptr)) { LEAK_TRACE; } @@ -351,7 +351,7 @@ void FileEntry::sortOrigins() bool FileEntry::recurseParents(std::wstring &path, const DirectoryEntry *parent) const { - if (parent == NULL) { + if (parent == nullptr) { return false; } else { // don't append the topmost parent because it is the virtual data-root @@ -480,7 +480,7 @@ void DirectoryEntry::addFromBSA(const std::wstring &originName, std::wstring &di void DirectoryEntry::propagateOrigin(int origin) { m_Origins.insert(origin); - if (m_Parent != NULL) { + if (m_Parent != nullptr) { m_Parent->propagateOrigin(origin); } } @@ -515,13 +515,13 @@ void DirectoryEntry::addFiles(FilesOrigin &origin, wchar_t *buffer, int bufferOf _snwprintf(buffer + bufferOffset, MAXPATH_UNICODE - bufferOffset, L"\\*"); - HANDLE searchHandle = NULL; + HANDLE searchHandle = nullptr; if (SupportOptimizedFind()) { - searchHandle = ::FindFirstFileExW(buffer, FindExInfoBasic, &findData, FindExSearchNameMatch, NULL, + searchHandle = ::FindFirstFileExW(buffer, FindExInfoBasic, &findData, FindExSearchNameMatch, nullptr, FIND_FIRST_EX_LARGE_FETCH); } else { - searchHandle = ::FindFirstFileExW(buffer, FindExInfoStandard, &findData, FindExSearchNameMatch, NULL, 0); + searchHandle = ::FindFirstFileExW(buffer, FindExInfoStandard, &findData, FindExSearchNameMatch, nullptr, 0); } if (searchHandle != INVALID_HANDLE_VALUE) { @@ -572,7 +572,7 @@ void DirectoryEntry::removeFile(const std::wstring &filePath, int *origin) std::wstring dirName = filePath.substr(0, pos); std::wstring rest = filePath.substr(pos + 1); DirectoryEntry *entry = getSubDirectoryRecursive(dirName, false); - if (entry != NULL) { + if (entry != nullptr) { entry->removeFile(rest, origin); } } @@ -608,7 +608,7 @@ void DirectoryEntry::removeDir(const std::wstring &path) std::wstring dirName = path.substr(0, pos); std::wstring rest = path.substr(pos + 1); DirectoryEntry *entry = getSubDirectoryRecursive(dirName, false); - if (entry != NULL) { + if (entry != nullptr) { entry->removeDir(rest); } } @@ -707,12 +707,12 @@ FilesOrigin &DirectoryEntry::getOriginByName(const std::wstring &name) const int DirectoryEntry::getOrigin(const std::wstring &path, bool &archive) { - const DirectoryEntry *directory = NULL; + const DirectoryEntry *directory = nullptr; const FileEntry::Ptr file = searchFile(path, &directory); - if (file.get() != NULL) { + if (file.get() != nullptr) { return file->getOrigin(archive); } else { - if (directory != NULL) { + if (directory != nullptr) { return directory->anyOrigin(); } else { return -1; @@ -732,13 +732,13 @@ std::vector DirectoryEntry::getFiles() const const FileEntry::Ptr DirectoryEntry::searchFile(const std::wstring &path, const DirectoryEntry **directory) const { - if (directory != NULL) { - *directory = NULL; + if (directory != nullptr) { + *directory = nullptr; } if ((path.length() == 0) || (path == L"*")) { // no file name -> the path ended on a (back-)slash - if (directory != NULL) { + if (directory != nullptr) { *directory = this; } return FileEntry::Ptr(); @@ -751,9 +751,9 @@ const FileEntry::Ptr DirectoryEntry::searchFile(const std::wstring &path, const auto iter = m_Files.find(ToLower(path)); if (iter != m_Files.end()) { return m_FileRegister->getFile(iter->second); - } else if (directory != NULL) { + } else if (directory != nullptr) { DirectoryEntry *temp = findSubDirectory(path); - if (temp != NULL) { + if (temp != nullptr) { *directory = temp; } } @@ -761,7 +761,7 @@ const FileEntry::Ptr DirectoryEntry::searchFile(const std::wstring &path, const // file is in in a subdirectory, recurse into the matching subdirectory std::wstring pathComponent = path.substr(0, len); DirectoryEntry *temp = findSubDirectory(pathComponent); - if (temp != NULL) { + if (temp != nullptr) { return temp->searchFile(path.substr(len + 1), directory); } } @@ -776,7 +776,7 @@ DirectoryEntry *DirectoryEntry::findSubDirectory(const std::wstring &name) const return *iter; } } - return NULL; + return nullptr; } @@ -808,7 +808,7 @@ DirectoryEntry *DirectoryEntry::getSubDirectory(const std::wstring &name, bool c new DirectoryEntry(name, this, originID, m_FileRegister, m_OriginConnection)); return *iter; } else { - return NULL; + return nullptr; } } @@ -825,8 +825,8 @@ DirectoryEntry *DirectoryEntry::getSubDirectoryRecursive(const std::wstring &pat return getSubDirectory(path, create); } else { DirectoryEntry *nextChild = getSubDirectory(path.substr(0, pos), create, originID); - if (nextChild == NULL) { - return NULL; + if (nextChild == nullptr) { + return nullptr; } else { return nextChild->getSubDirectoryRecursive(path.substr(pos + 1), create, originID); } @@ -888,7 +888,7 @@ void FileRegister::unregisterFile(FileEntry::Ptr file) } // unregister from directory - if (file->getParent() != NULL) { + if (file->getParent() != nullptr) { file->getParent()->removeFile(file->getIndex()); } } @@ -944,7 +944,7 @@ void FileRegister::removeOriginMulti(std::set indices, int ori // only when disabling an origin that is probably frequently the case std::set parents; BOOST_FOREACH (const FileEntry::Ptr &file, removedFiles) { - if (file->getParent() != NULL) { + if (file->getParent() != nullptr) { parents.insert(file->getParent()); } } -- cgit v1.3.1