//取上层目录路径 char *top_dir(const char *inpath, char *outpath) { int len; size_t count = 0; char *p = NULL; len = strlen(inpath); char tmp[len + 1]; char path[len + 1]; memset(tmp, '\0', sizeof(tmp)); memset(path, '\0', sizeof(tmp)); strcpy(path, inpath); //检查是否为绝对路径 if (*path != '/') { return NULL; } else { //去掉inpath最后的'/' if ( *(path + strlen(path) -1) == '/') { *(path + strlen(path) -1) = '\0'; } //统计'/'的个数 count = get_char_num(path, '/'); //若路径为根目录,或者上层目录就是根目录,则返回 if ( 1 == strlen(path) ) { return NULL; } else if ( (strlen(path) > 1) && (1 == count)) { return NULL; } //返回上层目录路径 p = NULL; p = strrchr(path, '/'); *p = '\0'; strcpy(outpath, path); return outpath; } return NULL; }
uint16 Font::drawString(Screen *screen, const char *str, uint16 string_len, uint16 x, uint16 y, uint8 color, uint8 highlight_color) { uint16 i; bool highlight = false; uint16 font_len = 0; for(i=0;i<string_len;i++) { if(str[i] == '@') highlight = true; else { if(!isalpha(str[i])) highlight = false; font_len += drawChar(screen, get_char_num(str[i]), x + font_len, y, highlight ? highlight_color : color); } } highlight = false; return font_len; }