Пример #1
0
static err_t EnumDir(filestream* p,const tchar_t* Exts,bool_t ExtFilter,streamdir* Item)
{
	struct dirent *Dirent;

	if (!p->FindDir)
		return ERR_END_OF_FILE;

	Item->FileName[0] = 0;
    Item->Size = INVALID_FILEPOS_T;

	while (!Item->FileName[0] && (Dirent = readdir(p->FindDir)) != NULL)
	{
	    tchar_t FilePath[MAXPATH];
	    struct stat file_stats;
        
        if (Dirent->d_name[0]=='.') // skip hidden files and current directory
            continue;

	    tcscpy_s(FilePath, TSIZEOF(FilePath), p->DirPath);
	    tcscat_s(FilePath, TSIZEOF(FilePath), Dirent->d_name);
	    tcscpy_s(Item->FileName,TSIZEOF(Item->FileName), Dirent->d_name);

	    stat(FilePath, &file_stats);

	    Item->ModifiedDate = LinuxToDateTime(file_stats.st_mtime);
	    if (S_ISDIR(file_stats.st_mode))
        {
            Item->Type = FTYPE_DIR;
		    Item->Size = INVALID_FILEPOS_T;
        }
	    else
	    {
		    Item->Size = file_stats.st_size;
		    Item->Type = CheckExts(Item->FileName,Exts);

			if (!Item->Type && ExtFilter)
				Item->FileName[0] = 0; // skip
	    }
	}

	if (!Item->FileName[0])
	{
		closedir(p->FindDir);
		p->FindDir = NULL;
		return ERR_END_OF_FILE;
	}

	return ERR_NONE;
}
Пример #2
0
static bool_t VorbisHeader(ogg* p,oggstream* s)
{
	tchar_t URL[MAXPATH];

	if (vorbis_synthesis_headerin(&s->Info,&s->Comment,&s->OggPacket)<0)
		return 0;

	PacketFormatClear(&s->Stream.Format);
	s->Stream.Format.Type = PACKET_AUDIO;
	s->Stream.Format.Format.Audio.Channels = s->Info.channels;
	s->Stream.Format.Format.Audio.SampleRate = s->Info.rate;
	s->Stream.Format.ByteRate = s->Info.bitrate_nominal >> 3;

	if (p->Format.Reader->Input->Get(p->Format.Reader->Input,STREAM_URL,URL,sizeof(URL))==ERR_NONE &&
		CheckExts(URL,T("ogg:A")) != 0)
		s->Stream.Format.Format.Audio.Format = AUDIOFMT_VORBIS_INTERNAL_AUDIO;
	else
		s->Stream.Format.Format.Audio.Format = AUDIOFMT_VORBIS_INTERNAL_VIDEO;

	s->Vorbis = 1;
	s->MediaRateDen = TICKSPERSEC;
	s->MediaRateNum = s->Info.rate;
	return 1;
}
Пример #3
0
static err_t EnumDir(filestream* p,const tchar_t* Exts,bool_t ExtFilter,streamdir* Item)
{
	iox_dirent_t Dirent;

	Item->FileName[0] = 0;
	Item->DisplayName[0] = 0;

    if (p->DevNo>=0)
    {
        static const tchar_t* const Devices[] =
        {
            "mass:",
            //"cdrom:", //driver doesn't support directory listing
            "hdd:",
            //"host:",  //driver doesn't support directory listing
            "cdda:",
            "cdfs:",
            "smb:",
            NULL,
        };
        for (;!Item->FileName[0];++p->DevNo)
        {
            int fd;
            const tchar_t* URL = Devices[p->DevNo];
            if (!URL)
                break;

        	fd = fileXioDopen(URL);
            if (fd>=0)
            {
                fileXioDclose(fd);
    	        tcscpy_s(Item->FileName,TSIZEOF(Item->FileName), URL);
	            Item->ModifiedDate = INVALID_DATETIME_T;
                Item->Type = FTYPE_DIR;
		        Item->Size = INVALID_FILEPOS_T;
            }
        }
    }
    else
    {
	    if (p->FindDir<0)
		    return ERR_END_OF_FILE;

	    while (!Item->FileName[0])
	    {
            if (fileXioDread(p->FindDir,&Dirent)<=0)
                break;

			if (Dirent.name[0]=='.') // skip unix/mac hidden files
				continue;

	        tcscpy_s(Item->FileName,TSIZEOF(Item->FileName), Dirent.name);
          
	        Item->ModifiedDate = PS2ToDateTime(Dirent.stat.mtime);
	        if (FIO_S_ISDIR(Dirent.stat.mode))
            {
                Item->Type = FTYPE_DIR;
		        Item->Size = INVALID_FILEPOS_T;
            }
	        else
	        {
		        Item->Size = Dirent.stat.size;
		        Item->Type = CheckExts(Item->FileName,Exts);

			    if (!Item->Type && ExtFilter)
				    Item->FileName[0] = 0; // skip
	        }
	    }
    }

	if (!Item->FileName[0])
	{
        if (p->FindDir>=0)
        {
		    fileXioDclose(p->FindDir);
		    p->FindDir = -1;
        }
		return ERR_END_OF_FILE;
	}

	return ERR_NONE;
}