static void OutputArrayValues(parsercontext *p, const tchar_t *name, tchar_t *values[], size_t size) { tchar_t Path[MAXPATH]; tchar_t Value[MAXPATH]; textwriter Output, StringOutput; size_t i; stprintf_s(Value, TSIZEOF(Value), T("res_%s"), name); for (i=0; i<size; ++i) { stprintf_s(Path, TSIZEOF(Path), T("values-%s"), values[i]); FolderCreate((nodecontext*)p, Path); if (PathIsFolder((nodecontext*)p, Path)) { tcscat_s(Path, TSIZEOF(Path), T("/resinfo.xml")); memset(&Output,0,sizeof(Output)); Output.Stream = StreamOpen(p, Path, SFLAG_WRONLY|SFLAG_CREATE); TextElementXML(p, &Output, T("resources")); TextElementBegin(&StringOutput, &Output, T("string")); TextAttrib(&StringOutput, T("name"), Value, TYPE_STRING); TcsToUpper(Path, TSIZEOF(Path), values[i]); TextElementEndData(&StringOutput, Path); TextElementEnd(&Output); StreamClose(Output.Stream); } } }
static int Command(benchresult* p,int Cmd) { if (Cmd == BENCHRESULT_SAVE) { tchar_t URL[MAXPATH]; tchar_t FileName[32]; stprintf_s(FileName,TSIZEOF(FileName),T("bench_%06d_%06d"),(int)(p->TimeDate/1000000000),(int)((p->TimeDate/1000)%1000000)); SaveDocument(FileName,p->Log,URL,TSIZEOF(URL)); ShowMessage(LangStr(BENCHRESULT_ID,NODE_NAME),LangStr(BENCHRESULT_ID,BENCHRESULT_SAVED),URL); return ERR_NONE; } return ERR_INVALID_PARAM; }
err_t CreateUrlPart(nodecontext *Context, tchar_t *Out, size_t OutLen, const tchar_t *URL, filepos_t Offset, size_t Length, const tchar_t *Mime) { datetime_t FileDate; if (!URL || !URL[0]) return ERR_INVALID_DATA; stprintf_s(Out,OutLen,T("urlpart://%s"),URL); tcsreplace(Out,OutLen,URLPART_SEPARATOR,URLPART_SEP_ESCAPE); tcscat_s(Out,OutLen,URLPART_SEPARATOR); if (Offset > 0) stcatprintf_s(Out,OutLen,T("ofs=%d#"),(int)Offset); // TODO: support 64 bits offset if (Length > 0) stcatprintf_s(Out,OutLen,T("len=%d#"),(int)Length); if (Mime) stcatprintf_s(Out,OutLen,T("mime=%s#"),Mime); FileDate = FileDateTime(Context,URL); if (FileDate != INVALID_DATETIME_T) stcatprintf_s(Out,OutLen,T("date=%d#"),(int)FileDate); return ERR_NONE; }
int RunCommand(anynode *p, const tchar_t *Cmd, const tchar_t *CmdParams, bool_t Silent) { STARTUPINFO si; PROCESS_INFORMATION pi; DWORD returnCode; tchar_t Command[4096]; int Flags = Silent ? CREATE_NO_WINDOW : 0; stprintf_s(Command,TSIZEOF(Command),T("%s %s"),Cmd, CmdParams); ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); if (!CreateProcess(NULL,Command,NULL,NULL,FALSE,Flags,NULL,NULL,&si,&pi)) return -1; while (GetExitCodeProcess(pi.hProcess, &returnCode) && returnCode==STILL_ACTIVE) Sleep(100); return (int)returnCode; }
void SlowVideo(char* Video,int BPP,int Width,int Height,int StrideX,int StrideY,int32_t* Result) { if (BPP == 16) { int64_t t0,t1,t; int nv,ns; int Mul,Len; int SystemLength = 512*1024; char* System = (char*) malloc( SystemLength ); //hopefully cpu cache will be smaller if (System) { TRY_BEGIN if (StrideX < 0) { StrideX = -StrideX; Video -= StrideX * (Width - 1); } if (StrideY < 0) { StrideY = -StrideY; Video -= StrideY * (Height - 1); } if (StrideX > StrideY) { Swap(&Width,&Height); Swap(&StrideX,&StrideY); } Len = (Width*BPP) >> 3; if (Len>32 && !IsBadWritePtr(Video,Len) && !IsBadReadPtr(Video,Len)) { int i; int Rows = SystemLength / Len; memset(System,0,Rows*Len); memcpy(System,Video,Len); BeginCounter(&t); t >>= 1; // 0.5 sec SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_HIGHEST); nv=0; GetCounter(&t0); t0 += t; do { for (i=0;i<Rows;++i) memcpy(Video,System,Len); nv++; GetCounter(&t1); } while (t1 < t0); ns=0; GetCounter(&t0); t0 += t; do { for (i=0;i<Rows;i++) memcpy(System+i*Len,System,Len); ns++; GetCounter(&t1); } while (t1 < t0); Mul = 6; if (nv*Mul >= ns) *Result = 0; // fast else *Result = 1; // slow (video memory or in general) SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_NORMAL); EndCounter(); #ifdef BENCH { tchar_t Msg[256]; stprintf_s(Msg,TSIZEOF(Msg),T("Video %d\nSystem %d\nResult %d"),nv,ns,*Result); MessageBox(NULL,Msg,T(""),MB_OK|MB_SETFOREGROUND); } #endif } TRY_END free(System); }
static int Init(benchresult* p) { node* Player = Context()->Player; node* Platform = Context()->Platform; node* Format; node* Input; node* VOutput; node* AOutput; winunit y; int i; int Frames; int Samples; int Bytes; tick_t Tick; tick_t OrigTick; point SizeSrc; point SizeDst; packetformat Video; packetformat Audio; tchar_t Buffer[256]; fraction f; p->TimeDate = GetTimeDate(); Player->Get(Player,PLAYER_FORMAT,&Format,sizeof(Format)); Player->Get(Player,PLAYER_INPUT,&Input,sizeof(Input)); VOutput = NULL; AOutput = NULL; OrigTick = 0; Frames = 0; Samples = 0; Bytes = 0; memset(&Video,0,sizeof(Video)); memset(&Audio,0,sizeof(Audio)); stprintf_s(p->Log,TSIZEOF(p->Log),LangStrDef(BENCHRESULT_ID,BENCHRESULT_LOG),Context()->ProgramName,Context()->ProgramVersion); tcscat_s(p->Log,TSIZEOF(p->Log),T("\n\n")); if (Format) { int No; pin Pin; packetformat PacketFormat; Format->Get(Format,FORMAT_FILEPOS,&Bytes,sizeof(Bytes)); for (No=0;Format->Get(Format,FORMAT_STREAM+No,&Pin,sizeof(Pin))==ERR_NONE;++No) if (Pin.Node && Format->Get(Format,(FORMAT_STREAM+No)|PIN_FORMAT,&PacketFormat,sizeof(PacketFormat))==ERR_NONE) { if (PacketFormat.Type == PACKET_VIDEO) { Video = PacketFormat; Player->Get(Player,PLAYER_VOUTPUT,&VOutput,sizeof(VOutput)); if (VOutput) VOutput->Get(VOutput,OUT_TOTAL,&Frames,sizeof(Frames)); } if (PacketFormat.Type == PACKET_AUDIO) { Audio = PacketFormat; Player->Get(Player,PLAYER_AOUTPUT,&AOutput,sizeof(AOutput)); if (AOutput) { packetformat Format; AOutput->Get(AOutput,OUT_TOTAL,&Samples,sizeof(Samples)); if (AOutput->Get(AOutput,OUT_INPUT|PIN_FORMAT,&Format,sizeof(Format))==ERR_NONE && Format.Type == PACKET_AUDIO) { if (Format.Format.Audio.Bits>=8) Samples /= Format.Format.Audio.Bits/8; if (!(Format.Format.Audio.Flags & PCM_PLANES) && Format.Format.Audio.Channels) Samples /= Format.Format.Audio.Channels; } } } } } y = 4; Player->Get(Player,PLAYER_BENCHMARK,&Tick,sizeof(Tick)); if (Frames && Video.PacketRate.Num) OrigTick = Scale64(Frames,(int64_t)Video.PacketRate.Den*TICKSPERSEC,Video.PacketRate.Num); else if (Samples && Audio.Format.Audio.SampleRate) OrigTick = Scale(Samples,TICKSPERSEC,Audio.Format.Audio.SampleRate); if (Tick && OrigTick) { f.Num = OrigTick; f.Den = Tick; FractionToString(Buffer,TSIZEOF(Buffer),&f,1,2); AddItem(p,&y,BENCHRESULT_SPEED,Buffer); } if (Frames) { IntToString(Buffer,TSIZEOF(Buffer),Frames,0); AddItem(p,&y,BENCHRESULT_FRAMES,Buffer); } if (Samples) { IntToString(Buffer,TSIZEOF(Buffer),Samples,0); AddItem(p,&y,BENCHRESULT_SAMPLES,Buffer); } if (Bytes) { IntToString(Buffer,TSIZEOF(Buffer),Bytes/1024,0); tcscat_s(Buffer,TSIZEOF(Buffer),T(" KB")); AddItem(p,&y,BENCHRESULT_BYTES,Buffer); } y += 6; tcscat_s(p->Log,TSIZEOF(p->Log),T("\n")); TickToString(Buffer,TSIZEOF(Buffer),Tick,0,1,0); AddItem(p,&y,BENCHRESULT_TIME,Buffer); if (Frames && Tick) { f.Num = Frames; f.Den = Tick; Simplify(&f,MAX_INT/TICKSPERSEC,MAX_INT); f.Num *= TICKSPERSEC; FractionToString(Buffer,TSIZEOF(Buffer),&f,0,2); AddItem(p,&y,BENCHRESULT_FPS,Buffer); } if (Samples && Tick) { f.Num = Samples; f.Den = Tick; Simplify(&f,MAX_INT/TICKSPERSEC,MAX_INT); f.Num *= TICKSPERSEC; FractionToString(Buffer,TSIZEOF(Buffer),&f,0,0); AddItem(p,&y,BENCHRESULT_SRATE,Buffer); } if (Bytes && Tick) { f.Num = Scale(Bytes,8,1000); f.Den = Tick; Simplify(&f,MAX_INT/TICKSPERSEC,MAX_INT); f.Num *= TICKSPERSEC; if (f.Den && (f.Num/f.Den) > 1000) { Simplify(&f,MAX_INT,MAX_INT/1024); f.Den *= 1000; FractionToString(Buffer,TSIZEOF(Buffer),&f,0,1); tcscat_s(Buffer,TSIZEOF(Buffer),T(" Mbit/s")); } else { FractionToString(Buffer,TSIZEOF(Buffer),&f,0,0); tcscat_s(Buffer,TSIZEOF(Buffer),T(" kbit/s")); } AddItem(p,&y,BENCHRESULT_BANDWIDTH,Buffer); } y += 6; tcscat_s(p->Log,TSIZEOF(p->Log),T("\n")); if (OrigTick) { TickToString(Buffer,TSIZEOF(Buffer),OrigTick,0,1,0); AddItem(p,&y,BENCHRESULT_ORIG_TIME,Buffer); } if (Video.PacketRate.Num) { FractionToString(Buffer,TSIZEOF(Buffer),&Video.PacketRate,0,2); AddItem(p,&y,BENCHRESULT_ORIG_FPS,Buffer); } if (Audio.Format.Audio.SampleRate) { IntToString(Buffer,TSIZEOF(Buffer),Audio.Format.Audio.SampleRate,0); AddItem(p,&y,BENCHRESULT_ORIG_SRATE,Buffer); } if (Bytes && OrigTick) { f.Num = Scale(Bytes,8,1000); f.Den = OrigTick; Simplify(&f,MAX_INT/TICKSPERSEC,MAX_INT); f.Num *= TICKSPERSEC; if (f.Den && (f.Num/f.Den) > 1000) { f.Den *= 1000; FractionToString(Buffer,TSIZEOF(Buffer),&f,0,1); tcscat_s(Buffer,TSIZEOF(Buffer),T(" Mbit/s")); } else { FractionToString(Buffer,TSIZEOF(Buffer),&f,0,0); tcscat_s(Buffer,TSIZEOF(Buffer),T(" kbit/s")); } AddItem(p,&y,BENCHRESULT_ORIG_BANDWIDTH,Buffer); } if (Frames && Samples) { y += 9; WinLabel(&p->Win,&y,-1,-1,LangStr(BENCHRESULT_ID,BENCHRESULT_MSG),11,0,NULL); } tcscat_s(p->Log,TSIZEOF(p->Log),T("\n")); if (Input && Input->Get(Input,STREAM_URL,Buffer,sizeof(Buffer))==ERR_NONE) AddLog(p,BENCHRESULT_ID,BENCHRESULT_URL,Buffer); if (Input && Input->Get(Input,STREAM_LENGTH,&i,sizeof(i))==ERR_NONE) { IntToString(Buffer,TSIZEOF(Buffer),i,0); AddLog(p,BENCHRESULT_ID,BENCHRESULT_FILESIZE,Buffer); } if (Platform) { if (Platform->Get(Platform,PLATFORM_TYPE,Buffer,sizeof(Buffer))==ERR_NONE) AddLog(p,PLATFORM_ID,PLATFORM_TYPE,Buffer); if (Platform->Get(Platform,PLATFORM_VERSION,Buffer,sizeof(Buffer))==ERR_NONE) AddLog(p,PLATFORM_ID,PLATFORM_VERSION,Buffer); if (Platform->Get(Platform,PLATFORM_OEMINFO,Buffer,sizeof(Buffer))==ERR_NONE) AddLog(p,PLATFORM_ID,PLATFORM_OEMINFO,Buffer); ThreadSleep(GetTimeFreq()/10); if (Platform->Get(Platform,PLATFORM_CPUMHZ,&i,sizeof(i))==ERR_NONE) { IntToString(Buffer,TSIZEOF(Buffer),i,0); tcscat_s(Buffer,TSIZEOF(Buffer),T(" Mhz")); AddLog(p,PLATFORM_ID,PLATFORM_CPUMHZ,Buffer); } } if (VOutput) { tcscpy_s(Buffer,TSIZEOF(Buffer),LangStrDef(VOutput->Class,NODE_NAME)); if (VOutput->Get(VOutput,OUT_OUTPUT|PIN_FORMAT,&Video,sizeof(Video))==ERR_NONE) { if (Video.Format.Video.Direction & DIR_SWAPXY) SwapInt(&Video.Format.Video.Width,&Video.Format.Video.Height); stcatprintf_s(Buffer,TSIZEOF(Buffer),T(" %dx%d %dbits"),Video.Format.Video.Width,Video.Format.Video.Height,Video.Format.Video.Pixel.BitCount); } if (QueryAdvanced(ADVANCED_SLOW_VIDEO)) tcscat_s(Buffer,TSIZEOF(Buffer),T(" Slow")); if (QueryAdvanced(ADVANCED_COLOR_LOOKUP)) tcscat_s(Buffer,TSIZEOF(Buffer),T(" Lookup")); AddLog(p,PLAYER_ID,PLAYER_VOUTPUT,Buffer); } if (Player->Get(Player,PLAYER_BENCHMARK_SRC,&SizeSrc,sizeof(point))==ERR_NONE && Player->Get(Player,PLAYER_BENCHMARK_DST,&SizeDst,sizeof(point))==ERR_NONE && SizeSrc.x>0 && SizeSrc.y>0) { stprintf_s(Buffer,TSIZEOF(Buffer),T("%dx%d -> %dx%d"),SizeSrc.x,SizeSrc.y,SizeDst.x,SizeDst.y); AddLog(p,BENCHRESULT_ID,BENCHRESULT_ZOOM,Buffer); } if (AOutput) { tcscpy_s(Buffer,TSIZEOF(Buffer),LangStrDef(AOutput->Class,NODE_NAME)); if (AOutput->Get(AOutput,OUT_OUTPUT|PIN_FORMAT,&Audio,sizeof(Audio))==ERR_NONE) stcatprintf_s(Buffer,TSIZEOF(Buffer),T(" %dHz %dBits %dCh."),Audio.Format.Audio.SampleRate,Audio.Format.Audio.Bits,Audio.Format.Audio.Channels); AddLog(p,PLAYER_ID,PLAYER_AOUTPUT,Buffer); } return ERR_NONE; }
static int Init(win* p) { tchar_t s[256]; packetformat Format; int No; node* VOutput = NULL; node* Reader = NULL; node* Input = NULL; node* Player = Context()->Player; winunit y; Player->Get(Player,PLAYER_FORMAT,&Reader,sizeof(Reader)); Player->Get(Player,PLAYER_INPUT,&Input,sizeof(Input)); Player->Get(Player,PLAYER_VOUTPUT,&VOutput,sizeof(VOutput)); y = 4; if (Input) Info(p,Input,&y,0); if (Reader) { pin Pin; Info(p,Reader,&y,MEDIAINFO_FORMAT); Comment(p,(player*)Player,&y,-1); for (No=0;Reader->Get(Reader,FORMAT_STREAM+No,&Pin,sizeof(Pin))==ERR_NONE;++No) if (PlayerGetStream((player*)Player,No,&Format,NULL,0,NULL)) { y += 6; if (Format.Type != PACKET_NONE) { if (!PacketFormatName(&Format,s,TSIZEOF(s))) s[0] =0; WinPropLabel(p,&y,LangStr(PLAYER_ID,STREAM_NAME+Format.Type),s); } switch (Format.Type) { case PACKET_NONE: break; case PACKET_VIDEO: if (Pin.Node && Compressed(&Format.Format.Video.Pixel)) Info(p,Pin.Node,&y,MEDIAINFO_CODEC); if (Format.Format.Video.Width && Format.Format.Video.Height) { stprintf_s(s,TSIZEOF(s),T("%d x %d"),Format.Format.Video.Width,Format.Format.Video.Height); WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_SIZE),s); } if (Format.PacketRate.Num) { FractionToString(s,TSIZEOF(s),&Format.PacketRate,0,3); WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_FPS),s); } if (Format.ByteRate) { IntToString(s,TSIZEOF(s),(Format.ByteRate+62)/125,0); tcscat_s(s,TSIZEOF(s),T(" kbit/s")); // 1000byte/sec WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_BITRATE),s); } break; case PACKET_AUDIO: if (Pin.Node && Format.Format.Audio.Format != AUDIOFMT_PCM) Info(p,Pin.Node,&y,MEDIAINFO_CODEC); s[0] = 0; if (Format.Format.Audio.SampleRate) { IntToString(s+tcslen(s),TSIZEOF(s)-tcslen(s),Format.Format.Audio.SampleRate,0); tcscat_s(s,TSIZEOF(s),T(" Hz ")); } switch (Format.Format.Audio.Channels) { case 0: break; case 1: tcscat_s(s,TSIZEOF(s),LangStr(MEDIAINFO_ID,MEDIAINFO_AUDIO_MONO)); break; case 2: tcscat_s(s,TSIZEOF(s),LangStr(MEDIAINFO_ID,MEDIAINFO_AUDIO_STEREO)); break; default: stcatprintf_s(s,TSIZEOF(s),T("%d Ch"),Format.Format.Audio.Channels); break; } if (s[0]) WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_FORMAT),s); if (Format.ByteRate) { IntToString(s,TSIZEOF(s),(Format.ByteRate+62)/125,0); tcscat_s(s,TSIZEOF(s),T(" kbit/s")); // 1000bit/sec WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_BITRATE),s); } break; case PACKET_SUBTITLE: if (Pin.Node) Info(p,Pin.Node,&y,MEDIAINFO_CODEC); break; } Comment(p,(player*)Player,&y,No); } if (VOutput) { int Total = 0; int Dropped = 0; VOutput->Get(VOutput,OUT_TOTAL,&Total,sizeof(int)); VOutput->Get(VOutput,OUT_DROPPED,&Dropped,sizeof(int)); Total += Dropped; if (Total) { y += 6; IntToString(s,TSIZEOF(s),Total,0); WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_VIDEO_TOTAL),s); IntToString(s,TSIZEOF(s),Dropped,0); WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_VIDEO_DROPPED),s); Player->Get(Player,PLAYER_VSTREAM,&No,sizeof(No)); if (No>=0 && Reader->Get(Reader,(FORMAT_STREAM+No)|PIN_FORMAT,&Format,sizeof(Format))==ERR_NONE && Format.Type == PACKET_VIDEO && Format.PacketRate.Num) { Simplify(&Format.PacketRate,(1<<30)/Total,(1<<30)/Total); Format.PacketRate.Num *= Total - Dropped; Format.PacketRate.Den *= Total; FractionToString(s,TSIZEOF(s),&Format.PacketRate,0,3); WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_AVG_FPS),s); } } } } return ERR_NONE; }
static void UpdateList(openfile* p, bool_t Silent, int ListMode) { streamdir DirItem; stream* Stream; int Result; openitem New; LVITEM Item; int No=0; int Pos=0; int State = LVIS_FOCUSED; int Len; const tchar_t* s; bool_t HasHost; if (!p->Multiple || (p->Flags & OPENFLAG_SINGLE)) State |= LVIS_SELECTED; Len = tcslen(p->Path); if (Len && (p->Path[Len-1] == '\\' || p->Path[Len-1] == '/')) p->Path[--Len] = 0; tcscpy_s(p->Base,TSIZEOF(p->Base),p->Path); s = p->Path[0] ? p->Path : T("\\"); AddHistory(p,s); if (!ListMode) return; ++p->InUpdate; WaitBegin(); ShowWindow(p->WndList,SW_HIDE); ClearList(p); Item.mask=LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM; Item.pszText=T(""); Item.cchTextMax=1; Item.iSubItem=0; Stream = GetStream(p->Path,Silent); if (Stream) { s = GetMime(p->Path,NULL,0,&HasHost); if (*s) { Item.iImage=IMG_DIRUP; Item.iItem = No; Item.lParam = 0; ListView_InsertItem(p->WndList,&Item); ListView_SetItemText(p->WndList,No,0,T("..")); ListView_SetItemText(p->WndList,No,1,(tchar_t*)LangStr(OPENFILE_ID,OPENFILE_UP)); ++No; } Result = Stream->EnumDir(Stream,p->Path,p->Exts,*p->CurrentFileType!=-1,&DirItem); if (ListMode==2 && Result == ERR_FILE_NOT_FOUND && UpperPath(p->Path,p->Last,TSIZEOF(p->Last))) { WaitEnd(); --p->InUpdate; p->LastClick = -1; UpdateList(p,Silent,ListMode); return; } if (Result == ERR_NOT_DIRECTORY && !Silent) { New.FileName[0] = 0; New.Ext[0] = 0; New.Image = IMG_FILE; New.Size = 0; Item.lParam = (DWORD)malloc(sizeof(openitem)); if (Item.lParam) { p->Last[0] = 0; Pos = No; State = LVIS_SELECTED; PostMessage(p->Win.Wnd,WM_COMMAND,PLATFORM_OK,0); *(openitem*)Item.lParam = New; Item.iItem = No; Item.iImage = New.Image; ListView_InsertItem(p->WndList,&Item); ++No; } } if (Result == ERR_NONE) Stream->Get(Stream,STREAM_BASE,p->Base,sizeof(p->Base)); while (Result == ERR_NONE) { tchar_t Size[32]; tchar_t Date[32]; int i; for (i=0;i<No;++i) { LVITEM Item; Item.iItem=i; Item.iSubItem = 0; Item.mask=LVIF_PARAM; ListView_GetItem(p->WndList,&Item); if (Item.lParam && tcscmp(((openitem*)Item.lParam)->FileName,DirItem.FileName)==0) break; } if (i==No) { tchar_t DisplayName[MAXPATH]; tcscpy_s(New.FileName,TSIZEOF(New.FileName),DirItem.FileName); New.DisplayName = DirItem.DisplayName[0] != 0; tcscpy_s(DisplayName,TSIZEOF(DisplayName),New.DisplayName?DirItem.DisplayName:DirItem.FileName); Size[0] = 0; Date[0] = 0; if (DirItem.Size < 0) { New.Image = IMG_DIR; New.Size = 0; New.Date = 0; tcscpy_s(New.Ext,TSIZEOF(New.Ext),LangStr(OPENFILE_ID,OPENFILE_DIR)); tcscpy_s(New.Name,TSIZEOF(New.Name),DisplayName); //keep extension } else { switch (DirItem.Type) { case FTYPE_AUDIO: New.Image = IMG_AUDIO; break; case FTYPE_PLAYLIST: New.Image = IMG_PLAYLIST; break; case FTYPE_VIDEO: New.Image = IMG_VIDEO; break; default: New.Image = IMG_FILE; break; } New.Size = DirItem.Size; New.Date = DirItem.Date; SplitURL(DisplayName,NULL,0,NULL,0,New.Name,TSIZEOF(New.Name),New.Ext,TSIZEOF(New.Ext)); tcsupr(New.Ext); if (New.Size >= 0) { if (New.Size < 10000*1024) stprintf_s(Size,TSIZEOF(Size),T("%d KB"),New.Size/1024); else stprintf_s(Size,TSIZEOF(Size),T("%d MB"),New.Size/(1024*1024)); } if (New.Date >= 0) { FILETIME Time; SYSTEMTIME SysTime; Time.dwHighDateTime = (DWORD)(New.Date >> 32); Time.dwLowDateTime = (DWORD)(New.Date); if (FileTimeToSystemTime(&Time,&SysTime)) GetDateFormat(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&SysTime,NULL,Date,TSIZEOF(Date)); } } Item.lParam = (DWORD)malloc(sizeof(openitem)); if (Item.lParam) { *(openitem*)Item.lParam = New; Item.iItem = No; Item.iImage = New.Image; ListView_InsertItem(p->WndList,&Item); ListView_SetItemText(p->WndList,No,0,New.Name); ListView_SetItemText(p->WndList,No,1,New.Ext); ListView_SetItemText(p->WndList,No,2,Size); ListView_SetItemText(p->WndList,No,3,Date); ++No; } } Result = Stream->EnumDir(Stream,NULL,NULL,0,&DirItem); }
static void OutputValues(parsercontext *p, size_t size, size_t night, size_t density, size_t touchscreen, size_t keyboard, size_t textinput, size_t navstate, size_t navmethod) { tchar_t Path[MAXPATH]; textwriter Output, StringOutput; stprintf_s(Path, TSIZEOF(Path), T("values") T("-%s") // T("-%s") T("-%s") // T("-%s") // T("-%s") // T("-%s") // T("-%s") // T("-%s") ,Size[size] // ,Night[night] ,Density[density] // ,TouchScreen[touchscreen] // ,Keyboard[keyboard] // ,TextInput[textinput] // ,NavigationState[navstate] // ,NavigationMethod[navmethod] ); FolderCreate((nodecontext*)p, Path); if (PathIsFolder((nodecontext*)p, Path)) { tcscat_s(Path, TSIZEOF(Path), T("/resinfo.xml")); memset(&Output,0,sizeof(Output)); Output.Stream = StreamOpen(p, Path, SFLAG_WRONLY|SFLAG_CREATE); TextElementXML(p, &Output, T("resources")); TextElementBegin(&StringOutput, &Output, T("string")); TextAttrib(&StringOutput, T("name"), T("res_size"), TYPE_STRING); TcsToUpper(Path, TSIZEOF(Path), Size[size]); TextElementEndData(&StringOutput, Path); TextElementBegin(&StringOutput, &Output, T("string")); TextAttrib(&StringOutput, T("name"), T("res_night"), TYPE_STRING); TcsToUpper(Path, TSIZEOF(Path), Night[night]); TextElementEndData(&StringOutput, Path); TextElementBegin(&StringOutput, &Output, T("string")); TextAttrib(&StringOutput, T("name"), T("res_density"), TYPE_STRING); TcsToUpper(Path, TSIZEOF(Path), Density[density]); TextElementEndData(&StringOutput, Path); TextElementBegin(&StringOutput, &Output, T("string")); TextAttrib(&StringOutput, T("name"), T("res_touchscreen"), TYPE_STRING); TcsToUpper(Path, TSIZEOF(Path), TouchScreen[touchscreen]); TextElementEndData(&StringOutput, Path); TextElementBegin(&StringOutput, &Output, T("string")); TextAttrib(&StringOutput, T("name"), T("res_keyboard"), TYPE_STRING); TcsToUpper(Path, TSIZEOF(Path), Keyboard[keyboard]); TextElementEndData(&StringOutput, Path); TextElementBegin(&StringOutput, &Output, T("string")); TextAttrib(&StringOutput, T("name"), T("res_textinput"), TYPE_STRING); TcsToUpper(Path, TSIZEOF(Path), TextInput[textinput]); TextElementEndData(&StringOutput, Path); TextElementBegin(&StringOutput, &Output, T("string")); TextAttrib(&StringOutput, T("name"), T("res_navstate"), TYPE_STRING); TcsToUpper(Path, TSIZEOF(Path), NavigationState[navstate]); TextElementEndData(&StringOutput, Path); TextElementBegin(&StringOutput, &Output, T("string")); TextAttrib(&StringOutput, T("name"), T("res_navmethod"), TYPE_STRING); TcsToUpper(Path, TSIZEOF(Path), NavigationMethod[navmethod]); TextElementEndData(&StringOutput, Path); TextElementEnd(&Output); StreamClose(Output.Stream); } }