private void writeDir2FL(OutputStream out, FLDir dir, String indentTabs) throws UnsupportedEncodingException, IOException {
		if (!dir.isShared())
			return;

		//if (!dir.isRoot() || (dir.isRoot() && dir.hasFile()))
		if (!dir.isRoot())
			out.write((indentTabs + "<Directory Name=\"" + dir.getName() + "\">\n").getBytes("utf-8"));

		FLDir dirs[] = dir.getSubDirs().toArray(new FLDir[0]);
		for (FLDir d : dirs) {
			writeDir2FL(out, d, indentTabs + "\t");
		}

		FLFile files[] = dir.getFiles().toArray(new FLFile[0]);
		for (FLFile f : files) {
			if (f.shared && f.hash != null && !f.hash.isEmpty()) {
				out.write((indentTabs + "\t" + "<File Name=\"" + f.name + "\" Size=\"" + f.size + "\" TTH=\"" + f.hash + "\"/>\n")
						.getBytes("utf-8"));
			} else
				notifyMiscMsg(f + " not written to file list, since it is not shared or its hash is not set.");
		}

		//if (!dir.isRoot() || (dir.isRoot() && dir.hasFile()))
		if (!dir.isRoot())
			out.write((indentTabs + "</Directory>\n").getBytes());
	}