Not logged in
Diff

Differences From Artifact [225199667e]:

  • File src/deltacmd.c — part of check-in [b9a744e1c4] at 2010-06-21 19:28:50 on branch trunk — Fix a segfault that can occur if a corrupt delta gets into the archive. (user: drh size: 4522) [more...]

To Artifact [13a2d23330]:

  • File src/deltacmd.c — part of check-in [932825bc6a] at 2010-07-08 17:53:14 on branch trunk — Take care to close the connection to the database file before existing. This gives the database a chance to clean up (and, for example, delete WAL and shared-memory files). (user: drh size: 4578) [more...]

48
49
50
51
52
53
54
55

56
57
58
59

60
61
62
63

64
65
66
67
68

69
70
71
72
73
74
75
48
49
50
51
52
53
54

55
56
57
58

59
60
61
62

63
64
65
66
67

68
69
70
71
72
73
74
75







-
+



-
+



-
+




-
+







** Given two input files, create and output a delta that carries
** the first file into the second.
*/
void delta_create_cmd(void){
  Blob orig, target, delta;
  if( g.argc!=5 ){
    fprintf(stderr,"Usage: %s %s ORIGIN TARGET DELTA\n", g.argv[0], g.argv[1]);
    exit(1);
    fossil_exit(1);
  }
  if( blob_read_from_file(&orig, g.argv[2])<0 ){
    fprintf(stderr,"cannot read %s\n", g.argv[2]);
    exit(1);
    fossil_exit(1);
  }
  if( blob_read_from_file(&target, g.argv[3])<0 ){
    fprintf(stderr,"cannot read %s\n", g.argv[3]);
    exit(1);
    fossil_exit(1);
  }
  blob_delta_create(&orig, &target, &delta);
  if( blob_write_to_file(&delta, g.argv[4])<blob_size(&delta) ){
    fprintf(stderr,"cannot write %s\n", g.argv[4]);
    exit(1);
    fossil_exit(1);
  }
  blob_reset(&orig);
  blob_reset(&target);
  blob_reset(&delta);
}

/*
111
112
113
114
115
116
117
118

119
120
121
122

123
124
125
126

127
128
129
130
131

132
133
134
135
136
137
138
111
112
113
114
115
116
117

118
119
120
121

122
123
124
125

126
127
128
129
130

131
132
133
134
135
136
137
138







-
+



-
+



-
+




-
+







** Given an input files and a delta, apply the delta to the input file
** and write the result.
*/
void delta_apply_cmd(void){
  Blob orig, target, delta;
  if( g.argc!=5 ){
    fprintf(stderr,"Usage: %s %s ORIGIN DELTA TARGET\n", g.argv[0], g.argv[1]);
    exit(1);
    fossil_exit(1);
  }
  if( blob_read_from_file(&orig, g.argv[2])<0 ){
    fprintf(stderr,"cannot read %s\n", g.argv[2]);
    exit(1);
    fossil_exit(1);
  }
  if( blob_read_from_file(&delta, g.argv[3])<0 ){
    fprintf(stderr,"cannot read %s\n", g.argv[3]);
    exit(1);
    fossil_exit(1);
  }
  blob_delta_apply(&orig, &delta, &target);
  if( blob_write_to_file(&target, g.argv[4])<blob_size(&target) ){
    fprintf(stderr,"cannot write %s\n", g.argv[4]);
    exit(1);
    fossil_exit(1);
  }
  blob_reset(&orig);
  blob_reset(&target);
  blob_reset(&delta);
}

/*