const Path Instance::GetTmpPath(GenericString file) { Path path; path.Reserve( 255 ); if (uint length = ::GetTempPath( path.Capacity() + 1, path.Ptr() )) { if (length > path.Capacity() + 1) { path.Reserve( length - 1 ); length = ::GetTempPath( path.Capacity() + 1, path.Ptr() ); } if (length) path = GetLongPath( path.Ptr() ); } if (path.Length()) path.MakePretty( true ); else path << ".\\"; if (file.Empty()) file = L"nestopia.tmp"; path << file; return path; }
bool CFindFile::FindFirst(LPCWSTR wildcard, CFileInfoW &fileInfo) { if (!Close()) return false; if (g_IsNT) { WIN32_FIND_DATAW fd; _handle = ::FindFirstFileW(wildcard, &fd); #ifdef WIN_LONG_PATH if (_handle == INVALID_HANDLE_VALUE) { UString longPath; if (GetLongPath(wildcard, longPath)) _handle = ::FindFirstFileW(longPath, &fd); } #endif if (_handle != INVALID_HANDLE_VALUE) ConvertWIN32_FIND_DATA_To_FileInfo(fd, fileInfo); } else { WIN32_FIND_DATAA fd; _handle = ::FindFirstFileA(UnicodeStringToMultiByte(wildcard, GetCurrentCodePage()), &fd); if (_handle != INVALID_HANDLE_VALUE) ConvertWIN32_FIND_DATA_To_FileInfo(fd, fileInfo); } return (_handle != INVALID_HANDLE_VALUE); }
HANDLE CFindChangeNotification::FindFirst(LPCTSTR pathName, bool watchSubtree, DWORD notifyFilter) { _handle = ::FindFirstChangeNotification(pathName, BoolToBOOL(watchSubtree), notifyFilter); #ifdef WIN_LONG_PATH2 if (!IsHandleAllocated()) { UString longPath; if (GetLongPath(pathName, longPath)) _handle = ::FindFirstChangeNotificationW(longPath, BoolToBOOL(watchSubtree), notifyFilter); } #endif return _handle; }
HANDLE CFindChangeNotification::FindFirst(LPCWSTR pathName, bool watchSubtree, DWORD notifyFilter) { if (!g_IsNT) return FindFirst(UnicodeStringToMultiByte(pathName, GetCurrentCodePage()), watchSubtree, notifyFilter); _handle = ::FindFirstChangeNotificationW(pathName, BoolToBOOL(watchSubtree), notifyFilter); #ifdef WIN_LONG_PATH if (!IsHandleAllocated()) { UString longPath; if (GetLongPath(pathName, longPath)) _handle = ::FindFirstChangeNotificationW(longPath, BoolToBOOL(watchSubtree), notifyFilter); } #endif return _handle; }
bool CFindFile::FindFirst(LPCTSTR wildcard, CFileInfo &fileInfo) { if (!Close()) return false; WIN32_FIND_DATA fd; _handle = ::FindFirstFile(wildcard, &fd); #ifdef WIN_LONG_PATH2 if (_handle == INVALID_HANDLE_VALUE) { UString longPath; if (GetLongPath(wildcard, longPath)) _handle = ::FindFirstFileW(longPath, &fd); } #endif if (_handle == INVALID_HANDLE_VALUE) return false; ConvertWIN32_FIND_DATA_To_FileInfo(fd, fileInfo); return true; }
bool CFileBase::Create(LPCTSTR fileName, DWORD desiredAccess, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes) { if (!Close()) return false; _handle = ::CreateFile(NtPath(fileName), desiredAccess, shareMode, (LPSECURITY_ATTRIBUTES)NULL, creationDisposition, flagsAndAttributes | FILE_FLAG_POSIX_SEMANTICS, (HANDLE)NULL); #ifdef WIN_LONG_PATH2 if (_handle == INVALID_HANDLE_VALUE) { UString longPath; if (GetLongPath(fileName, longPath)) _handle = ::CreateFileW(longPath, desiredAccess, shareMode, (LPSECURITY_ATTRIBUTES)NULL, creationDisposition, flagsAndAttributes | FILE_FLAG_POSIX_SEMANTICS, (HANDLE)NULL); } #endif return (_handle != INVALID_HANDLE_VALUE); }
bool DeleteFileAlways(CFSTR name) { if (!MySetFileAttributes(name, 0)) return false; #ifndef _UNICODE if (!g_IsNT) { if (::DeleteFile(fs2fas(name))) return true; } else #endif { if (::DeleteFileW(fs2us(name))) return true; #ifdef WIN_LONG_PATH UString longPath; if (GetLongPath(name, longPath)) return BOOLToBool(::DeleteFileW(longPath)); #endif } return false; }
bool CFileBase::Create(LPCWSTR fileName, DWORD desiredAccess, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes) { if (!g_IsNT) return Create(UnicodeStringToMultiByte(fileName, ::AreFileApisANSI() ? CP_ACP : CP_OEMCP), desiredAccess, shareMode, creationDisposition, flagsAndAttributes); if (!Close()) return false; _handle = ::CreateFileW(NtPath(fileName), desiredAccess, shareMode, (LPSECURITY_ATTRIBUTES)NULL, creationDisposition, flagsAndAttributes | FILE_FLAG_POSIX_SEMANTICS, (HANDLE)NULL); #ifdef WIN_LONG_PATH if (_handle == INVALID_HANDLE_VALUE) { UString longPath; if (GetLongPath(fileName, longPath)) _handle = ::CreateFileW(longPath, desiredAccess, shareMode, (LPSECURITY_ATTRIBUTES)NULL, creationDisposition, flagsAndAttributes | FILE_FLAG_POSIX_SEMANTICS, (HANDLE)NULL); } #endif return (_handle != INVALID_HANDLE_VALUE); }
ff::String ff::GetOriginalCasePath(StringRef path) { String sz = GetShortPath(path); return GetLongPath(sz); }