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

       1                 : #ifndef __ARCHIVE_H
       2                 : #define __ARCHIVE_H
       3                 : 
       4                 : #include "types.hh"
       5                 : 
       6                 : 
       7                 : namespace nix {
       8                 : 
       9                 : 
      10                 : /* dumpPath creates a Nix archive of the specified path.  The format
      11                 :    is as follows:
      12                 : 
      13                 :    IF path points to a REGULAR FILE:
      14                 :      dump(path) = attrs(
      15                 :        [ ("type", "regular")
      16                 :        , ("contents", contents(path))
      17                 :        ])
      18                 : 
      19                 :    IF path points to a DIRECTORY:
      20                 :      dump(path) = attrs(
      21                 :        [ ("type", "directory")
      22                 :        , ("entries", concat(map(f, sort(entries(path)))))
      23                 :        ])
      24                 :        where f(fn) = attrs(
      25                 :          [ ("name", fn)
      26                 :          , ("file", dump(path + "/" + fn))
      27                 :          ])
      28                 : 
      29                 :    where:
      30                 : 
      31                 :      attrs(as) = concat(map(attr, as)) + encN(0) 
      32                 :      attrs((a, b)) = encS(a) + encS(b)
      33                 : 
      34                 :      encS(s) = encN(len(s)) + s + (padding until next 64-bit boundary)
      35                 : 
      36                 :      encN(n) = 64-bit little-endian encoding of n.
      37                 : 
      38                 :      contents(path) = the contents of a regular file.
      39                 : 
      40                 :      sort(strings) = lexicographic sort by 8-bit value (strcmp).
      41                 : 
      42                 :      entries(path) = the entries of a directory, without `.' and
      43                 :      `..'.
      44                 : 
      45                 :      `+' denotes string concatenation. */
      46                 : 
      47                 : struct DumpSink 
      48                 : {
      49            5692 :     virtual ~DumpSink() { }
      50                 :     virtual void operator () (const unsigned char * data, unsigned int len) = 0;
      51                 : };
      52                 : 
      53                 : void dumpPath(const Path & path, DumpSink & sink);
      54                 : 
      55                 : 
      56                 : struct RestoreSource
      57                 : {
      58             112 :     virtual ~RestoreSource() { }
      59                 :     
      60                 :     /* The callee should store exactly *len bytes in the buffer
      61                 :        pointed to by data.  It should block if that much data is not
      62                 :        yet available, or throw an error if it is not going to be
      63                 :        available. */
      64                 :     virtual void operator () (unsigned char * data, unsigned int len) = 0;
      65                 : };
      66                 : 
      67                 : void restorePath(const Path & path, RestoreSource & source);
      68                 : 
      69                 :  
      70                 : }
      71                 : 
      72                 : 
      73                 : #endif /* !__ARCHIVE_H */

Generated by: LTP GCOV extension version 1.1