static void saveas_list(GTKMusicBrowser *p, guint action, GtkWidget *w) { GTKMessageDialog oBox; string oMessage = string("What do you want to call this playlist?"); if (oBox.Show(oMessage.c_str(), "Save This List to Disk?", kMessageOkCancel, true, true) == kMessageReturnOk) { char *temp = oBox.GetEntryText(); if (!temp) return; for (unsigned int i = 0; i < strlen(temp); i++) if (temp[i] == '/') temp[i] = '_'; char *fadir = FreeampDir(NULL); string name = string(fadir) + string("/") + string(temp) + string(".m3u"); p->m_currentListName = string(name); delete [] fadir; p->SaveCurrentPlaylist(); } }
Error ThemeManager::AddTheme(string &oThemeFile, bool bRename) { string oThemeDest; bool bRenameFailed = false; char fcopy[_MAX_PATH], *filename = NULL, *ext = NULL; oThemeDest = FreeampDir(NULL) + string("/themes"); if (bRename) { ThemeZip oZip; string oName; if (IsntError(oZip.GetDescriptiveName(oThemeFile, oName)) && oName.length() > 0) { int i; for (i = oName.length() - 1; i >= 0; i--) if (!isalnum(oName[i]) && oName[i] != ' ') oName.erase(i, 1); oThemeDest += string("/") + oName + string(".fat"); } else bRenameFailed = true; } if (!bRename || bRenameFailed) { strcpy(fcopy, oThemeFile.c_str()); filename = strrchr(fcopy, '/'); if (filename) filename = filename + 1; else filename = fcopy; ext = strrchr(filename, '.'); if (ext) { *ext = '\0'; ext++; } if (!filename) filename = "unknown"; oThemeDest += string("/") + string(filename); if (ext) oThemeDest += string(".") + string(ext); } if (!CopyFile(oThemeFile.c_str(), oThemeDest.c_str(), false)) return kError_FileNotFound; // So the caller knows where the theme ended up oThemeFile = oThemeDest; return kError_NoErr; }
Error ThemeManager::GetThemeList(map<string, string> &oThemeFileMap) { WIN32_FIND_DATA find; HANDLE handle; char dir[_MAX_PATH], *ptr; uint32 len = sizeof(dir); string oThemePath, oThemeBasePath, oThemeFile; m_pContext->prefs->GetPrefString(kInstallDirPref, dir, &len); oThemeBasePath = string(dir) + "/themes"; oThemePath = oThemeBasePath + string("/*.*"); handle = FindFirstFile((char *)oThemePath.c_str(), &find); if(handle != INVALID_HANDLE_VALUE) do { oThemeFile = oThemeBasePath + string("/") + string(find.cFileName); ptr = strrchr(find.cFileName, '.'); if (ptr) { *ptr = 0; ptr++; } if (ptr && *ptr) { if (!strcasecmp("fat", ptr) || !strcasecmp("zip", ptr) || !strcasecmp("wsz", ptr)) oThemeFileMap[find.cFileName] = oThemeFile; } } while(FindNextFile(handle, &find)); oThemeBasePath = FreeampDir(NULL) + string("/themes"); struct stat st; if (-1 == stat(oThemeBasePath.c_str(), &st)) mkdir(oThemeBasePath.c_str(), 0755); oThemePath = oThemeBasePath + string("/*.*"); handle = FindFirstFile((char *)oThemePath.c_str(), &find); if(handle != INVALID_HANDLE_VALUE) do { oThemeFile = oThemeBasePath + string("/") + string(find.cFileName); ptr = strrchr(find.cFileName, '.'); if (ptr) { *ptr = 0; ptr++; } if (ptr && *ptr) { if (!strcasecmp("fat", ptr) || !strcasecmp("zip", ptr) || !strcasecmp("wsz", ptr)) oThemeFileMap[find.cFileName] = oThemeFile; } } while(FindNextFile(handle, &find)); #if 0 oThemeBasePath = "./themes"; oThemePath = oThemeBasePath + string("/*.fat"); handle = FindFirstFile((char *)oThemePath.c_str(), &find); if(handle != INVALID_HANDLE_VALUE) do { oThemeFile = oThemeBasePath + string("/") + string(find.cFileName); ptr = strrchr(find.cFileName, '.'); if (ptr) *ptr = 0; oThemeFileMap[find.cFileName] = oThemeFile; } while(FindNextFile(handle, &find)); #endif return kError_NoErr; }
Error ThemeManager::GetThemeList(map<string, string> &oThemeFileMap) { WIN32_FIND_DATA find; HANDLE handle; char dir[MAX_PATH], *ptr; uint32 len = sizeof(dir); string oThemePath, oThemeBasePath, oThemeFile; if (m_bDevelTheme) oThemeFileMap[THEME_IN_DEVEL] = m_oDevelTheme; m_pContext->prefs->GetPrefString(kInstallDirPref, dir, &len); oThemeBasePath = string(dir) + "/" + BRANDING_SHARE_PATH + "/themes"; oThemePath = oThemeBasePath + string("/*.*"); handle = FindFirstFile((char *)oThemePath.c_str(), &find); if(handle != INVALID_HANDLE_VALUE) { do { oThemeFile = oThemeBasePath + string("/") + string(find.cFileName); ptr = strrchr(find.cFileName, '.'); if (ptr) { *ptr = 0; ptr++; } if (ptr && *ptr) { if (!strcasecmp("fat", ptr) || !strcasecmp("zip", ptr) || !strcasecmp("wsz", ptr)) oThemeFileMap[find.cFileName] = oThemeFile; } } while(FindNextFile(handle, &find)); FindClose(handle); } char *fadir = FreeampDir(NULL); oThemeBasePath = string(fadir) + string("/themes"); delete [] fadir; struct stat st; if (-1 == stat(oThemeBasePath.c_str(), &st)) mkdir(oThemeBasePath.c_str(), 0755); oThemePath = oThemeBasePath + string("/*.*"); handle = FindFirstFile((char *)oThemePath.c_str(), &find); if (handle != INVALID_HANDLE_VALUE) { do { oThemeFile = oThemeBasePath + string("/") + string(find.cFileName); ptr = strrchr(find.cFileName, '.'); if (ptr) { *ptr = 0; ptr++; } if (ptr && *ptr) { if (!strcasecmp("fat", ptr) || !strcasecmp("zip", ptr) || !strcasecmp("wsz", ptr)) oThemeFileMap[find.cFileName] = oThemeFile; } } while(FindNextFile(handle, &find)); FindClose(handle); } oThemeBasePath = "./themes"; oThemePath = oThemeBasePath + string("/*.*"); handle = FindFirstFile((char *)oThemePath.c_str(), &find); if (handle != INVALID_HANDLE_VALUE) { do { oThemeFile = oThemeBasePath + string("/") + string(find.cFileName); ptr = strrchr(find.cFileName, '.'); if (ptr) { *ptr = 0; ptr++; } if (ptr && *ptr) { if (!strcasecmp("fat", ptr) || !strcasecmp("zip", ptr) || !strcasecmp("wsz", ptr)) oThemeFileMap[find.cFileName] = oThemeFile; } } while(FindNextFile(handle, &find)); FindClose(handle); } return kError_NoErr; }