void LoadLastPlaylist(HWND hwnd)
{
    char playlist[MAX_PATH];

    GetPrivateProfileString("Playlist","LastPlaylist","",playlist,MAX_PATH,szINIFileName);
    if (lstrcmpi(playlist,""))
    {
		OpenProgress(hwnd,PDT_SINGLE,"Playlist loading");
		LoadPlaylist(hwnd,playlist);
		CloseProgress();
		curNode=GetNodeByIndex((int)GetPrivateProfileInt("Playlist","LastNode",0,szINIFileName));
		if (curNode==NULL)
			curNode=list_start;
		ShowStats();
    }
}
Exemple #2
0
static int SynoddOne(char *szDev, BOOL blRead)
{
	int err = -1;
	int fd = -1;
	int counts = 0;
	ssize_t lProgressBytes = 0;
	unsigned long long ullProgTotalBytes = 0;
	unsigned long long ullTotalBytes = 0;
	FILE *fp = NULL;

	if (!szDev) {
		return -1;
	}
	
	if (0 > (fd = OpenDevice(szDev, blRead, 0))){
		err = errno;
		goto END;
	}

	if (0 > CheckDevice(fd, &ullTotalBytes)){
		err = errno;
		syslog(LOG_ERR, "%s(%d) failed to check [%s].", __FILE__, __LINE__, szDev);
		goto END;
	}

	//Open Progress File
	if (NULL == (fp = OpenProgress(szDev))) {
		goto END;
	}

	err = 0;
	while(1) {
		if (COUNTS_TO_CHECK == counts) {
			counts = 0;
			
			if (fd >= 0) {
				close(fd);
			}
			if (0 > (fd = OpenDevice(szDev, blRead, ullProgTotalBytes))){
				err = errno;
				goto END;
			}
		}
		if (blRead) {
			lProgressBytes = read(fd, gszBuf, sizeof(gszBuf));
		} else {
			lProgressBytes = write(fd, gszBuf, sizeof(gszBuf));
		}
		if (0 > lProgressBytes) {
			if (ENOSPC != errno) {
				syslog(LOG_ERR, "(%s/%d) %s [%s] failed, errno=%m"
					   ,__FILE__ ,__LINE__ , blRead?"read":"write", szDev);
				err = errno;
			}
			goto END;
		}
		ullProgTotalBytes += lProgressBytes;

		WriteProgress(fp, ullProgTotalBytes, ullTotalBytes);
		if (ullTotalBytes <= ullProgTotalBytes) {
			break;
		}

		counts++;
	}
END:
	if (0 <= fd) close(fd);
	if (NULL != fp) fclose(fp);
	return err;
}