bool_t PathIsFolder(nodecontext *p,const tchar_t* Path)
{
    // not all file systems supports fileXioGetstat
    if (tcsnicmp(Path,T("cdrom"),5)!=0)
    {
        int fd = fileXioDopen(Path);
	    if (fd >= 0)
        {
            fileXioDclose(fd);
		    return 1;
        }
    }
	return 0;
}
Example #2
0
void RelPath(tchar_t* Rel, int RelLen, const tchar_t* Path, const tchar_t* Base)
{
	size_t n;
	bool_t HasHost;
	const tchar_t* p = GetProtocol(Base,NULL,0,&HasHost);
	if (p != Base)
	{
		if (HasHost)
		{
			// include host name too
			tchar_t *a,*b;
			a = tcschr(p,'\\');
			b = tcschr(p,'/');
			if (!a || (b && b<a))
				a=b;
			if (a)
				p=a;
			else
				p+=tcslen(p);
		}

		// check if mime and host is the same
		n = p-Base;
		if (n>0 && n<tcslen(Path) && (Path[n]=='\\' || Path[n]=='/') && tcsnicmp(Path,Base,n)==0)
		{
			Base += n;
			Path += n;
		}
	}

	n = tcslen(Base);
	if (n>0 && n<tcslen(Path) && (Path[n]=='\\' || Path[n]=='/') && tcsnicmp(Path,Base,n)==0)
		Path += n+1;

	tcscpy_s(Rel,RelLen,Path);
}
Example #3
0
static int Create(rawimage* p)
{
	const tchar_t* Format = LangStr(p->Format.Format.Class,RAWIMAGE_FORMAT);
	if (tcsnicmp(Format,T("vcodec/"),7)==0)
		p->FourCC = StringToFourCC(Format+7,1);
	if (!p->FourCC)
		return ERR_INVALID_PARAM;
	p->Format.Init = (fmtfunc)Init;
	p->Format.Seek = (fmtseek)Seek;
	p->Format.ReadPacket = (fmtreadpacket)Packet;
	p->Format.FillQueue = (fmtfill)FillQueue;
	p->Format.Process = (fmtstreamprocess)ProcessStream;
	p->Format.Sended = (fmtstream)Sended;
	p->Format.Timing = 0;
	return ERR_NONE;
}
Example #4
0
static CFStringBuiltInEncodings GetEncoding(const tchar_t* From)
{
    if (!From)
		return kCFStringEncodingUTF8; // use UTF-8 internally
    else if (!From[0])
		return kCFStringEncodingASCII; // regular/default strings are ASCII
	else if (tcsicmp(From,T("ASCII"))==0)
		return kCFStringEncodingASCII;
	else if (tcsicmp(From,T("UTF-8"))==0)
		return kCFStringEncodingUTF8;
	else if (tcsicmp(From,T("UTF-16"))==0)
		return kCFStringEncodingUTF16;
	else if (tcsicmp(From,T("UTF-32"))==0)
		return kCFStringEncodingUTF32;
	else if (tcsnicmp(From,T("CP"),2)==0)
		return CFStringConvertWindowsCodepageToEncoding(atoi(From+2));

	return (CFStringBuiltInEncodings)kCFStringEncodingInvalidId;
}
Example #5
0
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;
}
Example #6
0
const tchar_t* GetProtocol(const tchar_t* URL, tchar_t* Proto, int ProtoLen, bool_t* HasHost)
{
	const tchar_t* s = tcschr(URL,':');
	if (s && s[1] == '/' && s[2] == '/')
	{
        while (URL<s && IsSpace(*URL)) ++URL;
		if (Proto)
			tcsncpy_s(Proto,ProtoLen,URL,s-URL);
		if (HasHost)
        {
            if (tcsnicmp(URL,T("urlpart"),7)==0)
                // skip this protocol for the Host checking
                GetProtocol(URL+10,NULL,0,HasHost);
            else
			*HasHost = tcsnicmp(URL,T("file"),4)!=0 &&
			           tcsnicmp(URL,T("conf"),3)!=0 &&
			           tcsnicmp(URL,T("res"),3)!=0 &&
			           tcsnicmp(URL,T("root"),4)!=0 &&
			           tcsnicmp(URL,T("mem"),3)!=0 &&
			           tcsnicmp(URL,T("pose"),4)!=0 &&
			           tcsnicmp(URL,T("vol"),3)!=0 &&
			           tcsnicmp(URL,T("slot"),4)!=0 &&
					   tcsnicmp(URL,T("simu"),4)!=0 &&
					   tcsnicmp(URL,T("local"),5)!=0 &&
					   tcsnicmp(URL,T("sdcard"),6)!=0;
        }
		s += 3;
	}
	else
	{
		if (HasHost)
			*HasHost = 0;
		if (Proto)
			tcscpy_s(Proto,ProtoLen,T("file"));
		s = URL;
	}
	return s;
}