-// IndexCopy::CopyWithReplace - Copy a section and replace text /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool IndexCopy::CopyWithReplace(FileFd &Target,const char *Tag,string New)
-{
- // Mangle the output filename
- const char *Start;
- const char *Stop;
- const char *Filename;
- Section->Find(Tag,Filename,Stop);
-
- /* We need to rewrite the filename field so we emit
- all fields except the filename file and rewrite that one */
- for (unsigned int I = 0; I != Section->Count(); I++)
- {
- Section->Get(Start,Stop,I);
- if (Start <= Filename && Stop > Filename)
- {
- char S[500];
- sprintf(S,"%s: %s\n",Tag,New.c_str());
- if (I + 1 == Section->Count())
- strcat(S,"\n");
- if (Target.Write(S,strlen(S)) == false)
- return false;
- }
- else
- {
- if (Target.Write(Start,Stop-Start) == false)
- return false;
- if (Stop[-1] != '\n')
- if (Target.Write("\n",1) == false)
- return false;
- }
- }
- if (Target.Write("\n",1) == false)
- return false;
-}
- /*}}}*/