× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hello,

On 10/10/2011 10:53 AM, DeLong, Eric wrote:
// Create an empty file:
callp close( open( lPath + '/' + lFile
: O_WRONLY + O_TRUNC + O_CREAT + O_CCSID
: S_IWUSR + S_IRUSR + S_IRGRP + S_IROTH
: 1252 )
);

Consider making this tiny adjustment to Eric's clever code:

// Create an empty file:
unlink( lPath + '/' + lFile);
callp close( open( lPath + '/' + lFile
: O_WRONLY + O_CREAT + O_CCSID + O_INHERITMODE
: 0
: 1252 )
);

The unlink() deletes the file if it exists. (a CCSID is only assigned when a new file is created.)

O_TRUNC isn't necessary -- that clears an existing file, and I've already told it to delete the existing file.

O_INHERITMODE derives the file's 'mode' (authorites) from that of the directory. Depending on your purpose, this may be a better default than hardcoding -rw-r--r--.

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.