void uie_albumart::func_CopyName() { if (!OpenClipboard(m_hWnd)) return; if (!EmptyClipboard()) { CloseClipboard(); return; } t_size len = m_path.get_length(); HGLOBAL hglbCopyMem = GlobalAlloc(GMEM_MOVEABLE, (len+1)*sizeof(TCHAR)); if (hglbCopyMem == NULL) { CloseClipboard(); return; } LPTSTR lptstrCopy = (LPTSTR)GlobalLock(hglbCopyMem); pfc::stringcvt::string_wide_from_utf8 path_wide(m_path); _tcscpy_s(lptstrCopy, len+1, path_wide); lptstrCopy[len] = 0; GlobalUnlock(hglbCopyMem); if (SetClipboardData(CF_UNICODETEXT, hglbCopyMem) == NULL) { GlobalFree(hglbCopyMem); CloseClipboard(); return; } CloseClipboard(); }
static bool file_exists(const std::string &path) { #ifdef _MSC_VER std::wstring path_wide(path.begin(), path.end()); return PathFileExists(path_wide.c_str()) && !PathIsDirectory(path_wide.c_str()); #else try { struct stat fileAtt; if (stat(path.c_str(), &fileAtt) == 0) { return S_ISREG(fileAtt.st_mode); } } catch(...) {} return false; #endif }