About fdo#46180 LO Base fails to connect to "*.DBF" files but connects OK to "*.dbf"

Lionel Elie Mamane lionel at mamane.lu
Mon Feb 20 04:50:22 PST 2012


On Mon, Feb 20, 2012 at 03:49:02AM -0800, julien2412 wrote:

> Michael Meeks wrote
>> On Sun, 2012-02-19 at 05:49 -0800, julien2412 wrote:
>>> I let a comment about this bug
>>> https://bugs.freedesktop.org/show_bug.cgi?id=46180#c3.
>>> I'm stucked because I don't know what's the use of the boolean variables
>>> quoted in the comment.

>> 	Does Lionel's feedback help ? :-)


> Now if I understand what Lionel said, I don't know if DBF files
> should be consider as DBase files.

> I didn't test what's the result with ODS, ODP, etc.  (instead of ods, odp,
> ...) files and I don't know what should it be :
> must we consider ODS is not ods for example ?

Usually, LibreOffice should not care about extensions at
all. Extensions are a hint for the desktop environment which program
to hand off a file to when the user asks "open this file".

You can try:

 mv foo.ods foo
 libreoffice foo
 mv bar.doc bar.ods
 libreoffice bar.ods

It will work: foo will be opened in calc, and bar.ods in writer (not
calc). For any file we are asked to open, we should look at file
*contents*, not file *name* to decide what to do with it.

Now, csv-style files pose a unique problem: it is not possible to
reliably sniff whether a file is a csv-style file, and we don't
actually treat files, but we treat directories that contain a bunch of
these files PLUS possibly other stuff, because each "table" will be in
its own file, so a "database" is really a directory (or directory
hierarchy if you want catalogs and schemas). So we need a way to sort
out the tables from the other "stuff". So it is a reasonable solution
(and possibly the best we can do) to rely on file extension to see
which file in the given directory we should treat as a "csv-style"
table. Theoretically, one could imagine a heuristic method based on
contents, but that could make more new problems than it solves.

dBase files are similar, but not quite. I understand that they, too,
contain only one table per file. But my strong guess is that they can
be reliably content-sniffed. So, for dBase files we should probably
completely abandon the "filename extension" stuff, and read a few
bytes from every file in the directory, and if the first bytes are the
dBase signature, consider it as a table from the database.

-- 
Lionel


More information about the LibreOffice mailing list