/* ######################################################################
File Listing - Manages a Cache of File -> Package names.
/* ######################################################################
File Listing - Manages a Cache of File -> Package names.
storage space down in the very special case of a diverted file no
extra bytes are allocated in the Node structure. Instead a diversion
is inserted directly into the hash table and its flag bit set. Every
lookup for that filename will always return the diversion.
The hash buckets are stored in sorted form, with diversions having
storage space down in the very special case of a diverted file no
extra bytes are allocated in the Node structure. Instead a diversion
is inserted directly into the hash table and its flag bit set. Every
lookup for that filename will always return the diversion.
The hash buckets are stored in sorted form, with diversions having
pointer, thus after a search all of the nodes owning that file can be
found by iterating down the bucket.
pointer, thus after a search all of the nodes owning that file can be
found by iterating down the bucket.
#include <apt-pkg/filelist.h>
#include <apt-pkg/mmap.h>
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/filelist.h>
#include <apt-pkg/mmap.h>
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
// FLCache::Header::CheckSizes - Check if the two headers have same *sz /*{{{*/
// ---------------------------------------------------------------------
/* Compare to make sure we are matching versions */
// FLCache::Header::CheckSizes - Check if the two headers have same *sz /*{{{*/
// ---------------------------------------------------------------------
/* Compare to make sure we are matching versions */
// ---------------------------------------------------------------------
/* This is one of two hashing functions. The other is inlined into the
GetNode routine. */
// ---------------------------------------------------------------------
/* This is one of two hashing functions. The other is inlined into the
GetNode routine. */
NodeIterator FromN = GetNode(From,From+strlen(From),0,true,true);
NodeIterator ToN = GetNode(To,To+strlen(To),0,true,true);
if (FromN.end() == true || ToN.end() == true)
NodeIterator FromN = GetNode(From,From+strlen(From),0,true,true);
NodeIterator ToN = GetNode(To,To+strlen(To),0,true,true);
if (FromN.end() == true || ToN.end() == true)
// Should never happen
if ((FromN->Flags & Node::Diversion) != Node::Diversion ||
(ToN->Flags & Node::Diversion) != Node::Diversion)
// Should never happen
if ((FromN->Flags & Node::Diversion) != Node::Diversion ||
(ToN->Flags & Node::Diversion) != Node::Diversion)
then we are trying to intermix diversions - very bad */
if (ToN->Pointer != 0 && ToN->Pointer != Diver)
{
// It could be that the other diversion is no longer in use
if ((DiverP[ToN->Pointer].Flags & Diversion::Touched) == Diversion::Touched)
then we are trying to intermix diversions - very bad */
if (ToN->Pointer != 0 && ToN->Pointer != Diver)
{
// It could be that the other diversion is no longer in use
if ((DiverP[ToN->Pointer].Flags & Diversion::Touched) == Diversion::Touched)
From,To,ToN.File(),ToN.Dir().Name());
// We can erase it.
From,To,ToN.File(),ToN.Dir().Name());
// We can erase it.
// Can only have one diversion of the same files
Diversion *Div = DiverP + Diver;
if ((Div->Flags & Diversion::Touched) == Diversion::Touched)
// Can only have one diversion of the same files
Diversion *Div = DiverP + Diver;
if ((Div->Flags & Diversion::Touched) == Diversion::Touched)
// ---------------------------------------------------------------------
/* Since the package pointer is indirected in all sorts of interesting ways
this is used to get a pointer to the owning package */
// ---------------------------------------------------------------------
/* Since the package pointer is indirected in all sorts of interesting ways
this is used to get a pointer to the owning package */