HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Lollipop
|
5.0.1_r1
下载
查看原文件
收藏
根目录
external
skia
experimental
Intersection
AddTestOutput
main.cpp
#include "SkStream.h" #include "SkString.h" #include "SkTDArray.h" #include
static bool replace(const char* fun, const char* dir, const char* filename, const char* marker, const char* marker2, const char* replace, size_t replaceLen) { SkString outFileStr(dir); outFileStr.append(filename); SkFILEStream opStreamIn(outFileStr.c_str()); if (!opStreamIn.isValid()) { SkDebugf("%s couldn't find %s\n", fun, outFileStr.c_str()); return false; } SkTDArray
opData; opData.setCount(opStreamIn.getLength()); size_t opLen = opData.count(); opStreamIn.read(opData.begin(), opLen); opStreamIn.setPath(NULL); SkFILEWStream opStreamOut(outFileStr.c_str()); if (!opStreamOut.isValid()) { SkDebugf("%s couldn't open for writing %s\n", fun, outFileStr.c_str()); return false; } char* opInsert = strstr(opData.begin(), marker); if (!opInsert) { SkDebugf("%s missing marker in %s\n", fun, outFileStr.c_str()); opStreamOut.write(opData.begin(), opLen); opStreamOut.flush(); return false; } const char* opInsertEnd = opInsert + strlen(marker); if (marker2) { char* opInsert2 = strstr(opInsert, marker2); if (!opInsert2) { SkDebugf("%s missing marker second half in %s\n", fun, outFileStr.c_str()); opStreamOut.write(opData.begin(), opLen); opStreamOut.flush(); return false; } opInsertEnd = opInsert2 + strlen(marker2); } opStreamOut.write(opData.begin(), opInsert - opData.begin()); opStreamOut.write(replace, replaceLen); opStreamOut.write(opInsertEnd, opLen - (opInsertEnd - opData.begin())); opStreamOut.flush(); return true; } int main (int argc, char * const argv[]) { if (argc != 2) { SkDebugf("%s expected filename\n", argv[0]); return 0; } const char* dir = "../../experimental/Intersection/"; SkString inFileStr; if (argv[1][0] != '/') { inFileStr.append(dir); } inFileStr.append(argv[1]); SkFILEStream inFile(inFileStr.c_str()); if (!inFile.isValid()) { SkDebugf("%s couldn't find %s\n", argv[0], argv[1]); return 0; } SkTDArray
inData; inData.setCount(inFile.getLength()); size_t inLen = inData.count(); inFile.read(inData.begin(), inLen); inFile.setPath(NULL); char* insert = strstr(inData.begin(), "\n\n\n"); if (!insert) { SkDebugf("%s missing two blank line delimiter in %s\n", argv[0], argv[1]); return 0; } insert += 1; // include first blank line const char opMarker[] = "
" "\n" "\n" "
登录后可以享受更多权益
您还没有登录,登录后您可以:
收藏Android系统代码
收藏喜欢的文章
多个平台共享账号
去登录
首次使用?从这里
注册