LTP GCOV extension - code coverage report
Current view: directory - src/libutil - archive.hh
Test: app.info
Date: 2008-11-20 Instrumented lines: 3
Code covered: 100.0 % Executed lines: 3

       1                 : #ifndef __ARCHIVE_H
       2                 : #define __ARCHIVE_H
       3                 : 
       4                 : #include "types.hh"
       5                 : #include "serialise.hh"
       6                 : 
       7                 : 
       8                 : namespace nix {
       9                 : 
      10                 : 
      11                 : /* dumpPath creates a Nix archive of the specified path.  The format
      12                 :    is as follows:
      13                 : 
      14                 :    IF path points to a REGULAR FILE:
      15                 :      dump(path) = attrs(
      16                 :        [ ("type", "regular")
      17                 :        , ("contents", contents(path))
      18                 :        ])
      19                 : 
      20                 :    IF path points to a DIRECTORY:
      21                 :      dump(path) = attrs(
      22                 :        [ ("type", "directory")
      23                 :        , ("entries", concat(map(f, sort(entries(path)))))
      24                 :        ])
      25                 :        where f(fn) = attrs(
      26                 :          [ ("name", fn)
      27                 :          , ("file", dump(path + "/" + fn))
      28                 :          ])
      29                 : 
      30                 :    where:
      31                 : 
      32                 :      attrs(as) = concat(map(attr, as)) + encN(0) 
      33                 :      attrs((a, b)) = encS(a) + encS(b)
      34                 : 
      35                 :      encS(s) = encN(len(s)) + s + (padding until next 64-bit boundary)
      36                 : 
      37                 :      encN(n) = 64-bit little-endian encoding of n.
      38                 : 
      39                 :      contents(path) = the contents of a regular file.
      40                 : 
      41                 :      sort(strings) = lexicographic sort by 8-bit value (strcmp).
      42                 : 
      43                 :      entries(path) = the entries of a directory, without `.' and
      44                 :      `..'.
      45                 : 
      46                 :      `+' denotes string concatenation. */
      47                 : 
      48                 : struct PathFilter
      49             554 : {
      50             599 :     virtual ~PathFilter() { }
      51             247 :     virtual bool operator () (const Path & path) { return true; }
      52                 : };
      53                 : 
      54                 : extern PathFilter defaultPathFilter;
      55                 : 
      56                 : void dumpPath(const Path & path, Sink & sink,
      57                 :     PathFilter & filter = defaultPathFilter);
      58                 : 
      59                 : void restorePath(const Path & path, Source & source);
      60                 : 
      61                 :  
      62                 : }
      63                 : 
      64                 : 
      65                 : #endif /* !__ARCHIVE_H */

Generated by: LTP GCOV extension version 1.6