Tim,

Thanks. ftruncate is what I was looking for. I didn't find it by my
obviously lame search of the Infoma... uh, Knowledge center. (It's right
there under the category of IFS APIs. Searching for truncate or even trunc
finds it.)

Thanks again,
Michael



From: Tim Bronski <tim.bronski@xxxxxxxxx>
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Date: 03/12/2015 12:07 PM
Subject: Re: Shortening an IFS file
Sent by: "MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx>



If you open the file with O_TRUNC then the data will be cleared and the
size will be set to 0.
If you want to read in the data, change it and write back a different
size then open the file for O_RDWR, read your data, write your new data
back where you want it and then use ftruncate(fd, newsize); with the new
length and then close. Is that what you're looking to do?

Tim

On 3/12/2015 4:19 PM, MichaelQuigley@xxxxxxxxxx wrote:
So do you open the file without o_Trunc, read the data in, close the
file,
open it with o_Trunc, process the data already read, and write the
modified data back out? When the file is opened with o_Trunc, it wipes
out
the existing data before it can be read. (Unless I've done something
wrong
or simply don't understand.)

"MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx> wrote on 03/12/2015
10:14:08 AM:

From: Tim Brown <tim.bronski@xxxxxxxxx>
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Date: 03/12/2015 10:14 AM
Subject: Re: Shortening an IFS file
Sent by: "MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx>

I might have read your email too quickly. If you want to clear the
contents
of a file before writing back to it then use the open option i
suggested.
If you want to keep the contents up to a particular size then use
ftruncate.
On Mar 12, 2015 2:40 PM, "Tim Bronski" <tim.bronski@xxxxxxxxx> wrote:

If you're using open() then you should have O_TRUNC or'ed as a flag.

On 3/12/2015 2:32 PM, MichaelQuigley@xxxxxxxxxx wrote:

I'm writing a utility to remove some filler data from an IFS file.
I'm
using the The utility works great except that when I write the data
back
to the IFS, there is original data past where I want the new EOF to
be. I
can't for the life of me figure out how to shorten the file and set a
new
(shorter) end of file.

Any help would be greatly appreciated.

Thanks,
Michael Quigley
Computer Services
The Way International
www.TheWay.org

--
Need secure FTP? Download your native sFTP solution here:
www.arpeggiosoftware.com

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.