static void expandFileSongs(HWND playlistWnd, int index, ASAPInfo *info) { const char *fn = (const char *) SendMessage(mod.hMainWindow, WM_WA_IPC, index, IPC_GETPLAYLISTFILE); fileinfo fi; int song = extractSongNumber(fn, fi.file); if (song >= 0) return; if (ASAPInfo_IsOurFile(fi.file)) { if (loadModule(fi.file, module, &module_len) && ASAPInfo_Load(info, fi.file, module, module_len)) { SendMessage(playlistWnd, WM_WA_IPC, IPC_PE_DELETEINDEX, index); addFileSongs(playlistWnd, &fi, info, &index); } } else if (isATR(fi.file)) { FILE *fp = fopen(fi.file, "rb"); if (fp != NULL) { AATR *aatr = AATRStdio_New(fp); if (aatr != NULL) { size_t atr_fn_len = strlen(fi.file); BOOL found = FALSE; fi.file[atr_fn_len++] = '#'; for (;;) { const char *inside_fn = AATR_NextFile(aatr); if (inside_fn == NULL) break; if (ASAPInfo_IsOurFile(inside_fn)) { module_len = AATR_ReadCurrentFile(aatr, module, sizeof(module)); if (ASAPInfo_Load(info, inside_fn, module, module_len)) { size_t inside_fn_len = strlen(inside_fn); if (atr_fn_len + inside_fn_len + 4 <= sizeof(fi.file)) { memcpy(fi.file + atr_fn_len, inside_fn, inside_fn_len + 1); if (!found) { found = TRUE; SendMessage(playlistWnd, WM_WA_IPC, IPC_PE_DELETEINDEX, index); } addFileSongs(playlistWnd, &fi, info, &index); } } } } AATR_Delete(aatr); /* Prevent Winamp crash: 1. Play anything. 2. Open an ATR with no songs. 3. If the ATR deletes itself, Winamp crashes (tested with 5.581). Solution: leave the ATR on playlist. */ if (!found && SendMessage(mod.hMainWindow, WM_WA_IPC, 0, IPC_GETLISTLENGTH) > 1) SendMessage(playlistWnd, WM_WA_IPC, IPC_PE_DELETEINDEX, index); } fclose(fp); } } }
static void getFileInfo(char *file, char *title, int *length_in_ms) { char filename[MAX_PATH]; if (file == NULL || file[0] == '\0') file = current_filename_with_song; title_song = extractSongNumber(file, filename); if (title_song < 0) expandPlaylistSongs(); if (!loadModule(filename, module, &module_len)) return; if (!ASAP_GetModuleInfo(&title_module_info, filename, module, module_len)) return; if (title_song < 0) title_song = title_module_info.default_song; if (title != NULL) { waFormatTitle fmt_title = { NULL, NULL, title, 512, tagFunc, tagFreeFunc }; getTitle(title); // in case IPC_FORMAT_TITLE doesn't work... SendMessage(mod.hMainWindow, WM_WA_IPC, (WPARAM) &fmt_title, IPC_FORMAT_TITLE); } if (length_in_ms != NULL) *length_in_ms = getSongDuration(&title_module_info, title_song); }
static int isOurFile(char *fn) { char filename[MAX_PATH]; extractSongNumber(fn, filename); return ASAP_IsOurFile(filename); }