static err_t OpenDir(filestream* p,const tchar_t* URL,int UNUSED_PARAM(Flags)) { if (p->FindDir>=0) { fileXioDclose(p->FindDir); p->FindDir=-1; } if (!URL[0]) { p->DevNo = 0; return ERR_NONE; } p->DevNo = -1; p->FindDir = fileXioDopen(URL); if (p->FindDir<0) { int fd = fileXioOpen(URL,O_RDONLY,0); if (fd >= 0) { fileXioClose(fd); return ERR_NOT_DIRECTORY; } else return ERR_FILE_NOT_FOUND; } tcscpy_s(p->DirPath,TSIZEOF(p->DirPath),URL); AddPathDelimiter(p->DirPath,TSIZEOF(p->DirPath)); return ERR_NONE; }
static NOINLINE void AddFieldInt(pin* Pin,int Id,int Value) { tchar_t s[40]; GetFrameName(Id,s,TSIZEOF(s)); IntToString(s+tcslen(s),TSIZEOF(s)-tcslen(s),Value,0); AddField(Pin,Id,s); }
stream* GetStream(anynode *AnyNode, const tchar_t* URL, int Flags) { tchar_t Protocol[MAXPROTOCOL]; stream* Stream = NULL; fourcc_t FourCC; GetProtocol(URL,Protocol,TSIZEOF(Protocol),NULL); FourCC = NodeEnumClassStr(AnyNode,NULL,STREAM_CLASS,NODE_PROTOCOL,Protocol); #if defined(CONFIG_STREAM_CACHE) if ((Flags & (SFLAG_NO_CACHING|SFLAG_WRONLY|SFLAG_CREATE))==0) Stream = (stream*)NodeCreate(AnyNode,NodeClass_Meta(NodeContext_FindClass(AnyNode,FourCC),STREAM_CACHE_CLASS,META_PARAM_CUSTOM)); #endif if (!Stream) Stream = (stream*)NodeCreate(AnyNode,FourCC); if (Stream && (Flags & SFLAG_NON_BLOCKING)) Stream_Blocking(Stream,0); if (!Stream && !(Flags & SFLAG_SILENT)) { tcsupr(Protocol); NodeReportError(AnyNode,NULL,ERR_ID,ERR_PROTO_NOT_FOUND,Protocol); } #if defined(CONFIG_DEBUGCHECKS) if (Stream) tcscpy_s(Stream->URL,TSIZEOF(Stream->URL),URL); #endif return Stream; }
void FindFiles(nodecontext *p,const tchar_t* Path, const tchar_t* Mask,void(*Process)(const tchar_t*,void*),void* Param) { DIR* Directory; struct dirent* DirectoryInfo; tchar_t TPathToFile[MAXPATH]; Directory = opendir(Path); if (Directory) { while ( (DirectoryInfo = readdir(Directory)) != NULL ) { char* FileExtension = 0; FileExtension = strrchr(DirectoryInfo->d_name, '.'); if(FileExtension) { if (strcmp(Mask, FileExtension ) == 0 ) { tcscpy_s(TPathToFile, TSIZEOF(TPathToFile), Path); tcscat_s(TPathToFile, TSIZEOF(TPathToFile), DirectoryInfo->d_name); Process(TPathToFile, Param); } } } closedir(Directory); } }
static bool_t FindRunning(const tchar_t* CmdLine) { HWND Wnd; tchar_t ClassName[32]; int n = tcslen(ProgramName); tcscpy_s(ClassName,TSIZEOF(ClassName),ProgramName); tcscpy_s(ClassName+n,TSIZEOF(ClassName)-n,T("_Win")); Wnd = FindWindow(ClassName, NULL); if (Wnd) { HWND WndMain = Wnd; while (!IsWindowEnabled(Wnd)) { HWND Last = Wnd; EnumWindows(EnumWindowsProc,(LPARAM)&Wnd); if (Wnd == Last) break; } SetForegroundWindow(Wnd); if (CmdLine && CmdLine[0]) { COPYDATASTRUCT Data; Data.dwData = 0; Data.cbData = (tcslen(CmdLine)+1)*sizeof(tchar_t); Data.lpData = (PVOID)CmdLine; SendMessage(WndMain,WM_COPYDATA,(WPARAM)WndMain,(LPARAM)&Data); } return 1; } return 0; }
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 bool_t LoadDriver(gapi* p) { HMODULE GX; tchar_t Path[MAXPATH]; if (p->Windows) GetSystemPath(Path,TSIZEOF(Path),T("gx.dll")); else tcscpy_s(Path,TSIZEOF(Path),T("gx.dll")); if ((GX = LoadLibrary(Path))==NULL) { if (!p->Windows) { p->Windows = 1; return LoadDriver(p); } return 0; } if (p->GX) FreeLibrary(p->GX); p->GX = GX; GetProc(&p->GX,&p->GXOpenDisplay,T("?GXOpenDisplay@@YAHPAUHWND__@@K@Z"),0); GetProc(&p->GX,&p->GXCloseDisplay,T("?GXCloseDisplay@@YAHXZ"),0); GetProc(&p->GX,&p->GXBeginDraw,T("?GXBeginDraw@@YAPAXXZ"),0); GetProc(&p->GX,&p->GXEndDraw,T("?GXEndDraw@@YAHXZ"),0); GetProc(&p->GX,&p->GXGetDisplayProperties,T("?GXGetDisplayProperties@@YA?AUGXDisplayProperties@@XZ"),0); GetProc(&p->GX,&p->GXSetViewport,T("?GXSetViewport@@YAHKKKK@Z"),1); GetProc(&p->GX,&p->GXIsDisplayDRAMBuffer,T("?GXIsDisplayDRAMBuffer@@YAHXZ"),1); return p->GX!=NULL; }
// セルの文字列を設定(トラック名限定) BOOL CMusicalScoreTrackScaleView::SetCellString (long lTrack, CString strText) { CMusicalScoreFrame* pMusicalScoreFrame = (CMusicalScoreFrame*)GetParent (); CSekaijuApp* pSekaijuApp = (CSekaijuApp*)AfxGetApp (); CSekaijuDoc* pSekaijuDoc = GetDocument (); ASSERT (0 <= lTrack && lTrack < MAXMIDITRACKNUM); m_bSettingCellString = 1; MIDIData* pMIDIData = pSekaijuDoc->m_pMIDIData; MIDITrack* pMIDITrack = NULL; MIDIEvent* pTempTrack = NULL; MIDIEvent* pTempEvent = NULL; MIDITrack* pCloneTrack = NULL; MIDIEvent* pCloneEvent = NULL; long lFormat = MIDIData_GetFormat (pMIDIData); CHistoryUnit* pCurHistoryUnit = NULL; CString strHistoryName; long lValue = 0; long lNumber = 0; ASSERT (0 <= lTrack && lTrack < MAXMIDITRACKNUM); // トラック名 // 新しい履歴の用意 VERIFY (strHistoryName.LoadString (IDS_MODIFY_TRACKNAME)); VERIFY (pSekaijuDoc->AddHistoryUnit (strHistoryName)); VERIFY (pCurHistoryUnit = pSekaijuDoc->GetCurHistoryUnit ()); // 現在のトラックへのポインタを取得 pMIDITrack = pSekaijuDoc->GetTrack (lTrack); if (pMIDITrack == NULL) { return FALSE; } // 最初のトラック名イベントを探索 forEachEvent (pMIDITrack, pTempEvent) { if (MIDIEvent_GetKind (pTempEvent) == MIDIEVENT_TRACKNAME) { break; } } // 最初のトラック名イベントが見つからなかった場合 if (pTempEvent == NULL) { TCHAR szBuf2[2048]; memset (szBuf2, 0, sizeof (szBuf2)); str2codestr ((LPTSTR)(LPCTSTR)(strText), strText.GetLength (), szBuf2, TSIZEOF (szBuf2) - 1); VERIFY (pTempEvent = MIDIEvent_CreateTrackName (0, szBuf2)); VERIFY (MIDITrack_InsertEvent (pMIDITrack, pTempEvent)); VERIFY (pCurHistoryUnit->AddHistoryRecord (HISTORYRECORD_INSERTEVENT, pTempEvent)); } // 最初のトラック名が見つかった場合 else { VERIFY (pCurHistoryUnit->AddHistoryRecord (HISTORYRECORD_REMOVEEVENT, pTempEvent)); VERIFY (pCloneEvent = pSekaijuDoc->ReplaceMIDIEvent (pTempEvent)); TCHAR szBuf2[2048]; memset (szBuf2, 0, sizeof (szBuf2)); str2codestr ((LPTSTR)(LPCTSTR)(strText), strText.GetLength (), szBuf2, TSIZEOF (szBuf2) - 1); MIDIEvent_SetText (pCloneEvent, szBuf2); VERIFY (pCurHistoryUnit->AddHistoryRecord (HISTORYRECORD_INSERTEVENT, pCloneEvent)); } m_bSettingCellString = 0; return TRUE; }
static err_t Open(urlpart* p, const tchar_t* URL, int Flags) { err_t Result; const tchar_t *String, *Equal; tchar_t Value[MAXPATHFULL]; datetime_t Date = INVALID_DATETIME_T; String = tcsrchr(URL,URLPART_SEP_CHAR); if (!String) return ERR_INVALID_DATA; Clear(p); Node_SetData((node*)p,STREAM_URL,TYPE_STRING,URL); Equal = GetProtocol(URL,NULL,0,NULL); tcsncpy_s(Value,TSIZEOF(Value),Equal,String-Equal); tcsreplace(Value,TSIZEOF(Value),URLPART_SEP_ESCAPE,URLPART_SEPARATOR); Node_SetData((node*)p,URLPART_URL,TYPE_STRING,Value); while (String++ && *String) { Equal = tcschr(String,T('=')); if (Equal) { tchar_t *Sep = tcschr(Equal,T('#')); if (Sep) tcsncpy_s(Value,TSIZEOF(Value),Equal+1,Sep-Equal-1); else tcscpy_s(Value,TSIZEOF(Value),Equal+1); if (tcsncmp(String,T("ofs"),Equal-String)==0) p->Pos = StringToInt(Value,0); else if (tcsncmp(String,T("len"),Equal-String)==0) p->Length = StringToInt(Value,0); else if (tcsncmp(String,T("mime"),Equal-String)==0) Node_SetData((node*)p,URLPART_MIME,TYPE_STRING,Value); else if (tcsncmp(String,T("date"),Equal-String)==0) Date = StringToInt(Value,0); } String = tcschr(String,'#'); } if (Date!=INVALID_DATETIME_T && Date != FileDateTime(Node_Context(p),Node_GetDataStr((node*)p,URLPART_URL))) return ERR_INVALID_DATA; p->Input = GetStream(p,Node_GetDataStr((node*)p,URLPART_URL),Flags); if (!p->Input) return ERR_NOT_SUPPORTED; Stream_Blocking(p->Input,p->Blocking); Result = Stream_Open(p->Input,Node_GetDataStr((node*)p,URLPART_URL),Flags); if (Result == ERR_NONE && p->Pos!=INVALID_FILEPOS_T) // TODO: support asynchronous stream opening { if (Stream_Seek(p->Input,p->Pos,SEEK_SET)!=p->Pos) return ERR_INVALID_DATA; } return Result; }
static NOINLINE void AddFieldAttachment(pin* Pin,int Id,filepos_t Pos,int Size,const tchar_t* ContentType) { if (Size>0) { tchar_t s[512]; GetFrameName(Id,s,TSIZEOF(s)); stcatprintf_s(s,TSIZEOF(s),T(":%d:%d:%s"),(int)Pos,Size,ContentType); AddField(Pin,Id,s); } }
static NOINLINE void AddFieldStr(pin* Pin,int Id,const tchar_t* Value) { if (Value[0]) { tchar_t s[512]; GetFrameName(Id,s,TSIZEOF(s)); tcscat_s(s,TSIZEOF(s),Value); AddField(Pin,Id,s); } }
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; }
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; }
int StreamProtocolPriority(anynode *AnyNode, const tchar_t* URL) { tchar_t Protocol[MAXPROTOCOL]; GetProtocol(URL,Protocol,TSIZEOF(Protocol),NULL); if (tcsicmp(Protocol,T("file"))==0) // override for local files return PRI_MAXIMUM; return NodeClass_Priority(NodeContext_FindClass(AnyNode,NodeEnumClassStr(AnyNode,NULL,STREAM_CLASS,NODE_PROTOCOL,Protocol))); }
static err_t Open(filestream* p, const tchar_t* URL, int Flags) { if (p->fd>=0) fileXioClose(p->fd); p->Length = INVALID_FILEPOS_T; p->fd = -1; if (URL && URL[0]) { tchar_t Tmp[MAXPATH]; int size; int mode = 0; URL = CdromPath(URL,Tmp,TSIZEOF(Tmp)); if (Flags & SFLAG_WRONLY && !(Flags & SFLAG_RDONLY)) mode = O_WRONLY; else if (Flags & SFLAG_RDONLY && !(Flags & SFLAG_WRONLY)) mode = O_RDONLY; else mode = O_RDWR; if (Flags & SFLAG_CREATE) mode |= O_CREAT|O_TRUNC; p->fd = fileXioOpen(URL, mode, FIO_S_IRUSR | FIO_S_IWUSR | FIO_S_IXUSR | FIO_S_IRGRP | FIO_S_IWGRP | FIO_S_IXGRP | FIO_S_IROTH | FIO_S_IWOTH | FIO_S_IXOTH ); if (p->fd<0) { if ((Flags & (SFLAG_REOPEN|SFLAG_SILENT))==0) NodeReportError(p,NULL,ERR_ID,ERR_FILE_NOT_FOUND,URL); return ERR_FILE_NOT_FOUND; } tcscpy_s(p->URL,TSIZEOF(p->URL),URL); if ((size = fileXioLseek(p->fd, 0, SEEK_END)) >= 0) { fileXioLseek(p->fd, 0, SEEK_SET); p->Length = size; } } return ERR_NONE; }
bool_t UpperPath(tchar_t* Path, tchar_t* Last, size_t LastLen) { tchar_t *a,*b,*c; bool_t HasHost; tchar_t Mime[32]; if (!*Path) return 0; RemovePathDelimiter(Path); c = (tchar_t*)GetProtocol(Path,Mime,TSIZEOF(Mime),&HasHost); a = tcsrchr(c,'\\'); b = tcsrchr(c,'/'); if (!a || (b && b>a)) a=b; #ifdef TARGET_PS2SDK if (!a && (a = tcschr(c,':'))!=NULL) if (a[1]==0) a = NULL; #endif if (!a) { if (tcsicmp(Mime, T("smb")) == 0) { *c = 0; tcscpy_s(Last, LastLen, Path); return 1; } if (HasHost && tcsicmp(Mime, T("upnp"))!=0) return 0; a=c; if (!a[0]) // only mime left a=c=Path; } else ++a; if (Last) tcscpy_s(Last,LastLen,a); if (a==c) *a = 0; #ifdef TARGET_PS2SDK if (a>c && a[-1]==':') *a = 0; #endif while (--a>=c && (*a=='\\' || *a=='/')) *a = 0; return 1; }
static void Comment(win* Win,player* Player,winunit* y,int Stream) { tchar_t s[256]; int i; for (i=0;CommentNo[i];++i) if (Player->CommentByName(Player,Stream,PlayerComment(CommentNo[i]),s,TSIZEOF(s))) { if (Stream>=0 && Player->CommentByName(Player,-1,PlayerComment(CommentNo[i]),NULL,0)) continue; WinPropLabel(Win,y,LangStr(PLAYER_ID,CommentNo[i]),s); } if (Stream>=0) for (++i;CommentNo[i];++i) if (Player->CommentByName(Player,Stream,PlayerComment(CommentNo[i]),s,TSIZEOF(s))) WinPropLabel(Win,y,LangStr(PLAYER_ID,CommentNo[i]),s); }
static err_t OpenDir(filestream* p,const tchar_t* Path,int UNUSED_PARAM(Flags)) { if (p->FindDir) closedir(p->FindDir); if (Path[0]==0) Path = T("/"); p->FindDir = opendir(Path); if (!p->FindDir) { if (errno == ENOTDIR) return ERR_NOT_DIRECTORY; else return ERR_FILE_NOT_FOUND; } tcscpy_s(p->DirPath,TSIZEOF(p->DirPath),Path); AddPathDelimiter(p->DirPath,TSIZEOF(p->DirPath)); return ERR_NONE; }
bool_t FileExists(nodecontext *p,const tchar_t* Path) { // not all file systems supports fileXioGetstat tchar_t Tmp[MAXPATH]; int fd = fileXioOpen(CdromPath(Path,Tmp,TSIZEOF(Tmp)),O_RDONLY,0); if (fd >= 0) { fileXioClose(fd); return 1; } return 0; }
static int ReadList(pls* p,tchar_t* Path,int PathLen,tchar_t* DispName,int DispNameLen,tick_t* Length) { tchar_t s[MAXLINE]; int No,Len; int Result = ERR_END_OF_FILE; while (Result==ERR_END_OF_FILE && ParserLine(&p->Playlist.Parser,s,MAXLINE)) { tcsuprto(s,'='); if (stscanf(s,T("FILE%d ="),&No)==1) { if (No != p->Playlist.No && Fill(p,Path,PathLen,DispName,DispNameLen,Length)) Result = ERR_NONE; p->Playlist.No = No; tcscpy_s(p->File,TSIZEOF(p->File),tcschr(s,'=')+1); } else if (stscanf(s,T("TITLE%d ="),&No)==1) { if (No != p->Playlist.No && Fill(p,Path,PathLen,DispName,DispNameLen,Length)) Result = ERR_NONE; p->Playlist.No = No; tcscpy_s(p->Title,TSIZEOF(p->Title),tcschr(s,'=')+1); } else if (stscanf(s,T("LENGTH%d = %d"),&No,&Len)==2) { if (No != p->Playlist.No && Fill(p,Path,PathLen,DispName,DispNameLen,Length)) Result = ERR_NONE; p->Playlist.No = No; p->Length = Len; } } if (Result==ERR_END_OF_FILE && Fill(p,Path,PathLen,DispName,DispNameLen,Length)) Result = ERR_NONE; return Result; }
static void SendComments(oggstream* Stream) { tchar_t s[256]; if (Stream->Stream.Comment.Node) { int No; for (No=0;No<Stream->Comment.comments;++No) { UTF8ToTcs(s,TSIZEOF(s),Stream->Comment.user_comments[No]); Stream->Stream.Comment.Node->Set(Stream->Stream.Comment.Node,Stream->Stream.Comment.No,s,sizeof(s)); } } }
static void Info(win* Win,node* Node,winunit* y,int Name) { int No; datadef DataDef; if (Name) WinPropLabel(Win,y,LangStr(MEDIAINFO_ID,Name),LangStr(Node->Class,NODE_NAME)); for (No=0;NodeEnum(Node,No,&DataDef)==ERR_NONE;++No) if (!(DataDef.Flags & (DF_OUTPUT|DF_HIDDEN))) { tchar_t s[256]; tick_t Tick; int i; bool_t Ok = 0; switch (DataDef.Type) { case TYPE_TICK: Ok = Node->Get(Node,DataDef.No,&Tick,sizeof(Tick))==ERR_NONE; TickToString(s,TSIZEOF(s),Tick,0,1,0); break; case TYPE_INT: Ok = Node->Get(Node,DataDef.No,&i,sizeof(i))==ERR_NONE; IntToString(s,TSIZEOF(s),i,(DataDef.Flags & DF_HEX)!=0); if (DataDef.Flags & DF_KBYTE) tcscat_s(s,TSIZEOF(s),T(" KB")); break; case TYPE_STRING: Ok = Node->Get(Node,DataDef.No,s,sizeof(s))==ERR_NONE; break; } if (Ok) WinPropLabel(Win,y,DataDef.Name,s); } }
static HANDLE Load(const tchar_t* Name) { HANDLE Module; tchar_t Path[MAXPATH]; tchar_t *s; GetModuleFileName(NULL,Path,MAXPATH); s = tcsrchr(Path,'\\'); if (s) s[1]=0; tcscpy_s(Path+tcslen(Path),TSIZEOF(Path)-tcslen(Path),Name); Module = LoadLibrary(Path); if (!Module) Module = LoadLibrary(Name); return Module; }
// セルの文字列を取得(トラック名限定) CString CMusicalScoreTrackScaleView::GetCellString (long lTrack) { CMusicalScoreFrame* pMusicalScoreFrame = (CMusicalScoreFrame*)GetParent (); CSekaijuApp* pSekaijuApp = (CSekaijuApp*)AfxGetApp (); CSekaijuDoc* pSekaijuDoc = GetDocument (); ASSERT (0 <= lTrack && lTrack < MAXMIDITRACKNUM); MIDIData* pMIDIData = pSekaijuDoc->m_pMIDIData; MIDITrack* pMIDITrack = pSekaijuDoc->GetTrack (lTrack); MIDIEvent* pMIDIEvent = NULL; CString strText; strText = pSekaijuDoc->GetTrackName (pMIDITrack); TCHAR szBuf2[2048]; memset (szBuf2, 0, sizeof (szBuf2)); codestr2str ((LPTSTR)(LPCTSTR)strText, strText.GetLength (), szBuf2, TSIZEOF (szBuf2) - 1); strText = szBuf2; return strText; }
static int Create(advanced* p) { int Caps = QueryPlatform(PLATFORM_CAPS); video Desktop; QueryDesktop(&Desktop); p->Node.Enum = (nodeenum)Enum, p->Node.Get = (nodeget)Get, p->Node.Set = (nodeset)Set, p->SlowVideo = 0; #if defined(TARGET_WINCE) p->SystemVolume = QueryPlatform(PLATFORM_VER) < 421; #else p->SystemVolume = 0; #endif p->BenchFromPos = 0; p->VR41XX = 1; p->MemoryOverride = 0; p->KeyFollowDir = HaveDPad(); p->ColorLookup = !(Caps & CAPS_MIPS_VR41XX) && !(Caps & CAPS_ARM_XSCALE); p->OldShell = (Caps & CAPS_OLDSHELL) != 0; p->DropTolerance = (TICKSPERSEC*55)/1000; p->SkipTolerance = (TICKSPERSEC*700)/1000; p->AVOffset = 0; p->BlinkLED = 1; #if defined(TARGET_ANDROID) p->NoDeblocking = 1; #endif #if defined(TARGET_PALMOS) // causes major problems on Sony TJ35, like screen not turning off with audio, or hold/power button not working... //p->NoEventChecking = (QueryPlatform(PLATFORM_CAPS) & CAPS_SONY)!=0; #endif #if defined(TARGET_WINCE) { tchar_t FileName[MAXPATH]; GetSystemPath(FileName,TSIZEOF(FileName),T("BtCeAvIf.dll")); p->WidcommAudio = p->WidcommDLL = FileExits(FileName); } #endif return ERR_NONE; }
static void SavePos(openfile* p) { LVITEM Item; int n; p->Last[0] = 0; for (n=0;n<ListView_GetItemCount(p->WndList);++n) if (ListView_GetItemState(p->WndList,n,LVIS_FOCUSED)==LVIS_FOCUSED) { Item.iItem=n; Item.iSubItem = 0; Item.mask=LVIF_PARAM; ListView_GetItem(p->WndList,&Item); if (Item.lParam) tcscpy_s(p->Last,TSIZEOF(p->Last),((openitem*)Item.lParam)->Name); break; } }
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; }
int CheckExts(const tchar_t* URL, const tchar_t* Exts) { tchar_t Ext[MAXPATH]; tchar_t* Tail; intptr_t ExtLen; SplitPath(URL,NULL,0,NULL,0,Ext,TSIZEOF(Ext)); Tail = tcschr(Ext,'?'); if (Tail) *Tail = 0; ExtLen = tcslen(Ext); while (Exts) { const tchar_t* p = tcschr(Exts,':'); if (p && (ExtLen == p-Exts) && tcsnicmp(Ext,Exts,p-Exts)==0) return p[1]; // return type char Exts = tcschr(Exts,';'); if (Exts) ++Exts; } return 0; }
static err_t Open(filestream* p, const tchar_t* URL, int Flags) { if (p->fd != -1) close(p->fd); p->Length = INVALID_FILEPOS_T; p->fd = -1; if (URL && URL[0]) { struct stat file_stats; int mode = 0; if (Flags & SFLAG_WRONLY && !(Flags & SFLAG_RDONLY)) mode = O_WRONLY; else if (Flags & SFLAG_RDONLY && !(Flags & SFLAG_WRONLY)) mode = O_RDONLY; else mode = O_RDWR; if (Flags & SFLAG_CREATE) mode |= O_CREAT|O_TRUNC; //TODO: verify it works with Unicode files too p->fd = open(URL, mode, _RW_ACCESS_FILE); if (p->fd == -1) { if ((Flags & (SFLAG_REOPEN|SFLAG_SILENT))==0) NodeReportError(p,NULL,ERR_ID,ERR_FILE_NOT_FOUND,URL); return ERR_FILE_NOT_FOUND; } tcscpy_s(p->URL,TSIZEOF(p->URL),URL); if (stat(URL, &file_stats) == 0) p->Length = file_stats.st_size; } return ERR_NONE; }
void StreamLoginInfo(node* p, tchar_t* URL, bool_t Proxy) { tchar_t LoginPass[MAXPATH]; if (SplitAddr(URL,LoginPass,TSIZEOF(LoginPass),NULL,0)) { // extract the login:pass from the URL as there seems to be one tchar_t *s,*t; if (!Proxy) { Node_SetData(p,STREAM_FULL_URL,TYPE_STRING,URL); t = (tchar_t*)GetProtocol(URL,NULL,0,NULL); s = tcschr(t,T('@')); assert(s!=NULL); ++s; memmove(t, s, tcsbytes(s)); } t = (tchar_t*)GetProtocol(LoginPass,NULL,0,NULL); s=tcschr(t,T(':')); if (s) *s++ = 0; if (Proxy) { Node_SetData(p,STREAM_PROXY_PASSWORD,TYPE_STRING,s); Node_SetData(p,STREAM_PROXY_USERNAME,TYPE_STRING,t); } else { Node_SetData(p,STREAM_PASSWORD,TYPE_STRING,s); Node_SetData(p,STREAM_USERNAME,TYPE_STRING,t); } } else Node_RemoveData(p,STREAM_FULL_URL,TYPE_STRING); }