Re: Create empty files?

Victor Porton <porton.victor@xxxxxxxxx> writes:

On Jan 5, 10:19 pm, Mensanator <mensana...@xxxxxxx> wrote:
On Jan 5, 12:20 pm, Victor Porton <por...@xxxxxxxx> wrote:

An application uses files with IDs.

What of the following two variants is preferred?

1. To create empty IDs files at setup script.

2. If an IDs file is missing, treat it as if it would exist but empty.


Because empty files are not "empty" as far as the directory is

You should first answer first of my questions and only then the

From what you say about my second question, I assume that your answer
to the first question is:

2. If an IDs file is missing, treat it as if it would exist but empty.

The directory entry may not point to anything, but it takes up space.
A directory block can typically only hold 512 entries. When the
gets larger than that, a new block must be allocated. Very likely this
will result in a fragmented directory, making it much more difficult
to scan through. This may not be applicable to all OSes, I remember it
from observing some clown who put thousands of files into a single
and then wondered why it was slower than snake shit.

A few bytes of free space isn't a concern for the particular
application which I write.

Also adding to the source code processing of non-existing files would
probably eat comparable quantity of bytes as would creation of these

I'm more interested in programming beautify and clarity than in a few
bytes of free space.

Does anybody else have an opinion on my question?

We cannot answer to your first question without answering first to
your second question.

If you tried to answer to your second question, the answer to your
first question would become obvious, because the semantics of the two
options of the first question are different. (Ask yourself the
question of what should occur when the file is missing, in the first
case, or ask yourself what difference it makes if the file exists or
doesn't exist in the second case).

__Pascal Bourguignon__