bool FindAttrib( const char *xml, const char *name, CharBuf& val, const char *pend ){ if( !xml || !name ) return false; const char *pc = strstr_nostr( xml, name ); if( !pc || pc>=pend ) return false; // # Again, what are valid attribute name chars? if( pc>xml && (isalnum(pc[-1]) || pc[-1]=='_') ) return false; return GetAttrib( pc, name, val ) ? true : false; }
const char *GetAttrib( const char *xml, const char *name, int &i ){ CharBuf cb; xml = GetAttrib( xml, name, cb ); if( !xml ) return NULL; if( cb[0]=='0' && tolower(cb[1])=='x' ) sscanf( cb, "%x", &i ); else sscanf( cb.Str(), "%d", &i ); return xml; }
BOOL ringFile::copyTo(LPCTSTR lpNewName,BOOL bForceOverWrite) { if(lpNewName == NULL || *lpNewName == '\0') return FALSE; if(m_bExtern) { LPSTR lpbuf; int cnt = ReadAll(&lpbuf); if(cnt > 0) { ringFile rf = lpNewName; if(rf.isExist() && !bForceOverWrite) return FALSE; if(rf.Create(RF_NEW)) { if(rf.Write(lpbuf,cnt)) return TRUE; else return FALSE; } } return FALSE; } char dbuf[MAX_PATH]; DWORD attr = GetAttrib(); if((attr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) { if(lpNewName[strlen(lpNewName)-1] == '\\') wsprintf(dbuf,"%s%s\0\0",lpNewName,Filename()); else wsprintf(dbuf,"%s\\%s\0\0",lpNewName,Filename()); } else strcpy((char*)dbuf, (const char *)lpNewName); // 拷贝文件 return ::CopyFile(m_szFilename,dbuf,!bForceOverWrite); }
//如果文件已打开且以只读方式打开,失败 BOOL ringFile::SetFileTime(LPFILETIME lpCreate, LPFILETIME lpLast, LPFILETIME lpModify) { BOOL bOpen = FALSE; if(!m_hFile) { if(MASK_MATCH(GetAttrib(),FILE_ATTRIBUTE_DIRECTORY)) bOpen = Create(RF_EDIT,FILE_FLAG_BACKUP_SEMANTICS); else bOpen = Create(RF_EDIT); } // 设置时间 BOOL result = ::SetFileTime(m_hFile,lpCreate,lpLast,lpModify); if(bOpen) Close(); return result; }
BOOL ringFile::GetFileTime(LPFILETIME lpCreate, LPFILETIME lpLast, LPFILETIME lpModify) { BOOL result; if(m_hFile) result = ::GetFileTime(m_hFile,lpCreate,lpLast,lpModify); else { if(MASK_MATCH(GetAttrib(),FILE_ATTRIBUTE_DIRECTORY)) result = Open(RF_READ,RF_SHARE_READ,FILE_FLAG_BACKUP_SEMANTICS); else result = Open(); if(result) result = ::GetFileTime(m_hFile,lpCreate,lpLast,lpModify); Close(); } return result; }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{MAX_SWAP_INTERVAL} */ EGLint MaxSwapInterval(void) const { return GetAttrib(ConfigAttrib::MaxSwapInterval); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{CONFIG_ID} */ EGLint ConfigId(void) const { return GetAttrib(ConfigAttrib::ConfigId); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{CONFORMANT} */ Bitfield<eglplus::RenderableTypeBit> Conformant(void) const { return Bitfield<eglplus::RenderableTypeBit>( GetAttrib(ConfigAttrib::Conformant) ); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{SURFACE_TYPE} */ Bitfield<eglplus::SurfaceTypeBit> SurfaceTypes(void) const { return Bitfield<eglplus::SurfaceTypeBit>( EGLenum(GetAttrib(ConfigAttrib::SurfaceType)) ); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{RENDERABLE_TYPE} */ Bitfield<eglplus::RenderableTypeBit> RenderableTypes(void) const { return Bitfield<eglplus::RenderableTypeBit>( EGLenum(GetAttrib(ConfigAttrib::RenderableType)) ); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{COLOR_BUFFER_TYPE} */ eglplus::ColorBufferType ColorBufferType(void) const { return eglplus::ColorBufferType( EGLenum(GetAttrib(ConfigAttrib::ColorBufferType)) ); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{LUMINANCE_SIZE} */ EGLint LuminanceSize(void) const { return GetAttrib(ConfigAttrib::LuminanceSize); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{BLUE_SIZE} */ EGLint BlueSize(void) const { return GetAttrib(ConfigAttrib::BlueSize); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{GREEN_SIZE} */ EGLint GreenSize(void) const { return GetAttrib(ConfigAttrib::GreenSize); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{RED_SIZE} */ EGLint RedSize(void) const { return GetAttrib(ConfigAttrib::RedSize); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{NATIVE_RENDERABLE} */ EGLint NativeRenderable(void) const { return GetAttrib(ConfigAttrib::NativeRenderable); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{CONFIG_CAVEAT} */ eglplus::ConfigCaveat ConfigCaveat(void) const { return eglplus::ConfigCaveat( EGLenum(GetAttrib(ConfigAttrib::ConfigCaveat)) ); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{ALPHA_SIZE} */ EGLint AlphaSize(void) const { return GetAttrib(ConfigAttrib::AlphaSize); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{TRANSPARENT_TYPE} */ eglplus::TransparentType TransparentType(void) const { return eglplus::TransparentType( EGLenum(GetAttrib(ConfigAttrib::TransparentType)) ); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{DEPTH_SIZE} */ EGLint DepthSize(void) const { return GetAttrib(ConfigAttrib::DepthSize); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{RENDERABLE_TYPE} */ bool HasRenderableType(eglplus::RenderableTypeBit type) const { EGLenum a = GetAttrib(ConfigAttrib::RenderableType); EGLenum b = EGLenum(type); return (a & b) == b; }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{STENCIL_SIZE} */ EGLint StencilSize(void) const { return GetAttrib(ConfigAttrib::StencilSize); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{SURFACE_TYPE} */ bool HasSurfaceType(eglplus::SurfaceTypeBit type) const { EGLenum a = GetAttrib(ConfigAttrib::SurfaceType); EGLenum b = EGLenum(type); return (a & b) == b; }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{MAX_PBUFFER_WIDTH} */ EGLint MaxPbufferWidth(void) const { return GetAttrib(ConfigAttrib::MaxPbufferWidth); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{CONFORMANT} */ bool IsConformantTo(eglplus::RenderableTypeBit type) const { EGLenum a = GetAttrib(ConfigAttrib::Conformant); EGLenum b = EGLenum(type); return (a & b) == b; }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{MAX_PBUFFER_HEIGHT} */ EGLint MaxPbufferHeight(void) const { return GetAttrib(ConfigAttrib::MaxPbufferHeight); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{BUFFER_SIZE} */ EGLint BufferSize(void) const { return GetAttrib(ConfigAttrib::BufferSize); }
/** * @eglsymbols * @eglfunref{GetConfigAttrib} * @egldefref{MAX_PBUFFER_PIXELS} */ EGLint MaxPbufferPixels(void) const { return GetAttrib(ConfigAttrib::MaxPbufferPixels); }