private void addDirectoryToParentEntriesFile(final File CVSdir) throws IOException {
        synchronized (ksEntries) {
            final File parentCVSEntries = seekEntries(CVSdir.getParentFile().getParentFile());

            // only update if the file exists. The file will not exist in the
            // case where this is the top level of the module
            if (parentCVSEntries != null) {
                final File directory = parentCVSEntries.getParentFile();
                final File tempFile = new File(directory, "Entries.Backup"); // NOI18N
                tempFile.createNewFile();
                BufferedReader reader = null;
                BufferedWriter writer = null;
                try {
                    reader = new BufferedReader(new FileReader(parentCVSEntries));
                    writer = new BufferedWriter(new FileWriter(tempFile));

                    String line;

                    // As in the updateEntriesFile method the new Entry
                    // only may be written, if it does not exist
                    boolean written = false;

                    final Entry directoryEntry = new Entry();
                    directoryEntry.setName(CVSdir.getParentFile().getName());
                    directoryEntry.setDirectory(true);

                    while ((line = reader.readLine()) != null) {
                        if (line.trim().equals("D")) { // NOI18N
                            // do not write out this line
                            continue;
                        }

                        final Entry currentEntry = new Entry(line);
                        if ((currentEntry.getName() != null) && currentEntry.getName().equals(directoryEntry.getName())) {
                            writer.write(directoryEntry.toString());
                            written = true;
                        } else {
                            writer.write(line);
                        }
                        writer.newLine();
                    }

                    if (!written) {
                        writer.write(directoryEntry.toString());
                        writer.newLine();
                    }
                } finally {
                    try {
                        if (writer != null) {
                            writer.close();
                        }
                    } finally {
                        if (reader != null) {
                            reader.close();
                        }
                    }
                }

                if (t9yBeforeRename != null) {
                    t9yBeforeRename.run();
                }
                FileUtils.renameFile(tempFile, parentCVSEntries);
            }
        }
    }