Re: How can I easily determine the last charachter of a file?

2023-02-15 Thread ProtectAndHide via Digitalmars-d-learn
On Tuesday, 14 February 2023 at 18:30:05 UTC, seany wrote: Hello Consider the content of a file First line \n Second line data data data data ... last char My goal is to find out whether the last character is a new line or not. Please not, it will be sufficient if this w

Re: How can I easily determine the last charachter of a file?

2023-02-14 Thread Steven Schveighoffer via Digitalmars-d-learn
```d myFile.seek(-1, SEEK_END); ubyte c[1]; myFile.rawRead(c[]); if(c[0] == '\n') // ends in newline ``` -Steve

How can I easily determine the last charachter of a file?

2023-02-14 Thread seany via Digitalmars-d-learn
Hello Consider the content of a file First line \n Second line data data data data ... last char My goal is to find out whether the last character is a new line or not. Please not, it will be sufficient if this works on Linux. More specifically I want to insert a new li