#include <iostream> #include <fstream> #include <stdlib.h> #include <string> #include <string.h> using namespace std; void saveConfigFile( string filePath, string keyStr,string replaceStr){ fstream file(filePath.c_str()); string line; int n, count = 0; //create a temp file ofstream outfile("1.conf", ios::out | ios::trunc); //read the original file while (!file.eof()) { getline(file, line);//read one line //judge the line just read is the line to process if (strstr(line.c_str(), keyStr.c_str())) { outfile<<replaceStr<<endl; } else outfile << line << endl; } outfile.close(); file.close(); ofstream outfile1(filePath.c_str(), ios::out | ios::trunc); fstream file1("1.conf"); //write the temp file to the original file while (!file1.eof()) { getline(file1, line); outfile1 << line << endl; } outfile1.close(); file1.close(); //delete the temp file system("rm 1.conf"); } main(){ string filePath ="a.conf"; saveConfigFile("a.conf","sv-as-startup","[VOL_ATTRIBUTE]sv-as-startup,3,45,1,9;"); }
a.conf
#[VOL_DEFAULT_ATTRI]音频流名字,最小音量,最大音量,步长,默认值; [VOL_ATTRIBUTE]sv-as-tts,0,10,1,6; [VOL_ATTRIBUTE]sv-as-asr,0,10,1,6; [VOL_ATTRIBUTE]sv-as-music,0,35,1,10; [VOL_ATTRIBUTE]sv-as-link-phone,0,10,1,6; [VOL_ATTRIBUTE]sv-as-link-ring,0,10,1,6; [VOL_ATTRIBUTE]sv-as-link-asr,0,10,1,6; [VOL_ATTRIBUTE]sv-as-link-navi,0,10,1,6; [VOL_ATTRIBUTE]sv-as-bt-ring,0,10,1,6; [VOL_ATTRIBUTE]sv-as-asr-beep,0,10,1,6; [VOL_ATTRIBUTE]sv-as-bt-phone,0,10,1,6; [VOL_ATTRIBUTE]sv-as-key,0,100,10,60; [VOL_ATTRIBUTE]sv-as-startup,3,45,1,9; [VOL_ATTRIBUTE]sv-as-field,0,24,1,12; [VOL_ATTRIBUTE]sv-as-eq,0,24,1,12; [VOL_ATTRIBUTE]sv-as-sdvc,0,7,1,0; #[VOL_GROUPS]组内,音量绑定在一起,一个变化,组内audio id的音量跟着变化。 #[VOL_GROUPS]10,15,16; #[VOL_GROUPS]9,21;
原文链接: https://www.cnblogs.com/yuguangyuan/p/8520655.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍;
也有高质量的技术群,里面有嵌入式、搜广推等BAT大佬
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/397788
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!