Added better support for compressed .mag files. While magic doesn't
generate compressed .mag files itself, it is often very useful to compress a massive layout file to save disk space or to hit a github size target. The code change looks for files with either ".mag" (default) or ".mag.gz" extensions. No check is made to see if both files might exist at the same time and have incompatible content; it is up to the end user to manage the file compression.
This commit is contained in:
parent
203ece1a16
commit
00c692b140
|
|
@ -98,6 +98,9 @@ extern bool FileLocking;
|
|||
|
||||
/* Suffix for all Magic files */
|
||||
char *DBSuffix = ".mag";
|
||||
#ifdef HAVE_ZLIB
|
||||
char *DBZSuffix = ".mag.gz";
|
||||
#endif
|
||||
|
||||
/* Magic units per lambda (2 integers, representing (n / d) */
|
||||
int DBLambda[2] = {1, 1};
|
||||
|
|
@ -1483,15 +1486,28 @@ dbReadOpen(cellDef, setFileName, dereference, errptr)
|
|||
|
||||
/* If dereferencing, then use search paths first */
|
||||
if (!dereference)
|
||||
{
|
||||
f = PaLockZOpen(cellDef->cd_file, "r", DBSuffix, ".",
|
||||
(char *) NULL, &filename, &is_locked, &fd);
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
if (f == NULL)
|
||||
f = PaLockZOpen(cellDef->cd_file, "r", DBZSuffix, ".",
|
||||
(char *) NULL, &filename, &is_locked, &fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Fall back on the original method of using search paths. */
|
||||
|
||||
if (f == NULL)
|
||||
{
|
||||
f = PaLockZOpen(cellDef->cd_name, "r", DBSuffix, Path,
|
||||
CellLibPath, &filename, &is_locked, &fd);
|
||||
#ifdef HAVE_ZLIB
|
||||
if (f == NULL)
|
||||
f = PaLockZOpen(cellDef->cd_file, "r", DBZSuffix, Path,
|
||||
CellLibPath, &filename, &is_locked, &fd);
|
||||
#endif
|
||||
|
||||
if (f != NULL)
|
||||
{
|
||||
|
|
@ -1524,6 +1540,11 @@ dbReadOpen(cellDef, setFileName, dereference, errptr)
|
|||
{
|
||||
f = PaLockZOpen(cellDef->cd_file, "r", DBSuffix, ".",
|
||||
(char *) NULL, &filename, &is_locked, &fd);
|
||||
#ifdef HAVE_ZLIB
|
||||
if (f == NULL)
|
||||
f = PaLockZOpen(cellDef->cd_file, "r", DBZSuffix, ".",
|
||||
(char *) NULL, &filename, &is_locked, &fd);
|
||||
#endif
|
||||
if (f != NULL)
|
||||
if (DBVerbose)
|
||||
TxError("Warning: Dereferenced cell \"%s\" not "
|
||||
|
|
@ -1541,6 +1562,11 @@ dbReadOpen(cellDef, setFileName, dereference, errptr)
|
|||
{
|
||||
f = PaLockZOpen(cellDef->cd_name, "r", DBSuffix, Path,
|
||||
CellLibPath, &filename, &is_locked, &fd);
|
||||
#ifdef HAVE_ZLIB
|
||||
if (f == NULL)
|
||||
f = PaLockZOpen(cellDef->cd_name, "r", DBZSuffix, Path,
|
||||
CellLibPath, &filename, &is_locked, &fd);
|
||||
#endif
|
||||
if (errptr != NULL) *errptr = errno;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue