Re: Writing a character to the beginning of the same file




"SAM" <mshyamrao@xxxxxxxxx> wrote in message
news:1114660481.571702.267690@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> Scott McPhillips [MVP] wrote:
> > SAM wrote:
> >
> > > Hi,
> > >
> > > I have program that pre-appends a character to a file. it is not
> > > working.
> > >
> > > Here is the problem.
> > >
> > > I am not able to write a character to the beginning of the file
> without
> > > affecting the previous content.
> > >
> > > Is there any limit on the size of the line in UNIX text files?
> > >
> > > I am doubtful if there is a line length limit for a text file. If
> there
> > > is line limit then I can easily copy the content of the first line
> into
> > > a temporary byte array and add the new character to be added to
> another
> > > temporary byte array and append the old byte array to this new
> > > temporary byte array and write the contents of the new array into
> the
> > > same file at the beginning.
> > >
> > >
> > > can u please help me.
> > >
> > > SAM
> > >
> >
> > The issue has nothing to do with size of lines. There is no unused
> > space in a text file. Adding a character anywhere within a file
> makes
> > the file longer. Every byte after the insertion point must be
> rewritten
> > to its new location in the file.
> >
> > --
> > Scott McPhillips [VC++ MVP]
>
>
> So what is the solution to write a character to the beginning of the
> file and not affect the existing content.
>

you can't do that without modifying the said document's contents. A file has
a finite size, regardless of the lines involved. It starts somewhere. If you
preappend without regenerate the modifed document, you preappend potentially
into someone else's back yard.

The goal here is not how to preappend the file, its how to do so without
jeopardizing the integrity of the entire system.


.



Relevant Pages

  • Re: Writing a character to the beginning of the same file
    ... > SAM wrote: ... >> I have program that pre-appends a character to a file. ... >> affecting the previous content. ... >> a temporary byte array and add the new character to be added to ...
    (comp.programming)
  • Re: Need help with textboxes
    ... character into the input box. ... one of assigning the reference to a variable: ... All forms and their children are stored in an array ... No. Bracket property accessors allow their argument to be any string value. ...
    (comp.lang.javascript)
  • Help in Spanish translation of the description of UDFs
    ... functions of minimum / maximum values among elements of an array column. ... GETALLWORDS- Inserts the words from a string into a global dimensioned ... WORDTRAN- Searches a character string for occurrences of a first word, ... ARRAYSUM- Returns the sum of all or a specified range of numeric (and/or ...
    (microsoft.public.fox.helpwanted)
  • Re: Pointer
    ... require in input a pointer char: ... unsafe public static extern int OpenFile; ... What is it pointing to exactly, is it pointing to a "Unicode character" array or is it pointing to a "Single byte character" array or is it pointing to something else? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: problem with unhandled exception (acces violation) and undefined array/pointer
    ... If you pass a real array to a ... character dummy the extra arguments won't be there. ... occasional fortran user with limited knowledge, ... with compile and link options, ...
    (comp.lang.fortran)