From 774a9fab3dba195ce15283ec61cdd9d6f28b2c46 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Tue, 30 Jul 2013 18:31:33 +0000 Subject: [PATCH] [BUG_FIXED] Fix opening file problem from the network drive. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1090 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/ScitillaComponent/Buffer.cpp | 57 ++------------------ 1 file changed, 3 insertions(+), 54 deletions(-) diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index 8879f6a3..b04b6eed 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -893,68 +893,17 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Rea return success; } -BufferID FileManager::getBufferFromName(const TCHAR * name) +BufferID FileManager::getBufferFromName(const TCHAR * name) { - // Attempt to match by name first. TCHAR fullpath[MAX_PATH]; ::GetFullPathName(name, MAX_PATH, fullpath, NULL); ::GetLongPathName(fullpath, fullpath, MAX_PATH); - for(size_t i = 0; i < _buffers.size(); ++i) + for(size_t i = 0; i < _buffers.size(); i++) { if (!lstrcmpi(name, _buffers.at(i)->getFullPathName())) return _buffers.at(i)->getID(); } - - // If no buffer matches exactly by name, try another method. - HANDLE givenFile = ::CreateFile(name, - GENERIC_READ, - FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - - BY_HANDLE_FILE_INFORMATION givenFileInfo, currentFileInfo; - - if(givenFile == INVALID_HANDLE_VALUE) - return BUFFER_INVALID; - - if(! ::GetFileInformationByHandle(givenFile, &givenFileInfo)) - { - ::CloseHandle(givenFile); - return BUFFER_INVALID; - } - - ::CloseHandle(givenFile); - - const unsigned int bufferSize = _buffers.size(); - for(size_t i = 0; i < bufferSize; ++i) - { - HANDLE currentFile = ::CreateFile(_buffers.at(i)->getFullPathName(), - GENERIC_READ, - FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(currentFile != INVALID_HANDLE_VALUE) - { - if(::GetFileInformationByHandle(currentFile, ¤tFileInfo)) - { - if(currentFileInfo.dwVolumeSerialNumber == givenFileInfo.dwVolumeSerialNumber && - currentFileInfo.nFileIndexLow == givenFileInfo.nFileIndexLow && - currentFileInfo.nFileIndexHigh == givenFileInfo.nFileIndexHigh) - { - ::CloseHandle(currentFile); - return _buffers.at(i)->getID(); - } - } - ::CloseHandle(currentFile); - } - } - - return BUFFER_INVALID; + return BUFFER_INVALID; } BufferID FileManager::getBufferFromDocument(Document doc) {