Fossil SCM

Fill islink field in vfile table when adding files. Support symlinks in export. Make manifest_file_perm() return 2 for symlinks. Add file_perm() function, and use it instead of file_isexe() when we need both isexe and islink properties.

dmitry 2011-08-23 17:44 symlinks
Commit 4619361d585c8c52a827eb8a470c8e0cbe28f3e2
+3 -3
--- src/add.c
+++ src/add.c
@@ -106,13 +106,13 @@
106106
db_multi_exec("UPDATE vfile SET deleted=0"
107107
" WHERE pathname=%Q COLLATE %s", zPath, zCollate);
108108
}else{
109109
char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath);
110110
db_multi_exec(
111
- "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe)"
112
- "VALUES(%d,0,0,0,%Q,%d)",
113
- vid, zPath, file_isexe(zFullname));
111
+ "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe,islink)"
112
+ "VALUES(%d,0,0,0,%Q,%d,%d)",
113
+ vid, zPath, file_isexe(zFullname), file_islink(zFullname));
114114
fossil_free(zFullname);
115115
}
116116
if( db_changes() ){
117117
fossil_print("ADDED %s\n", zPath);
118118
return 1;
119119
--- src/add.c
+++ src/add.c
@@ -106,13 +106,13 @@
106 db_multi_exec("UPDATE vfile SET deleted=0"
107 " WHERE pathname=%Q COLLATE %s", zPath, zCollate);
108 }else{
109 char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath);
110 db_multi_exec(
111 "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe)"
112 "VALUES(%d,0,0,0,%Q,%d)",
113 vid, zPath, file_isexe(zFullname));
114 fossil_free(zFullname);
115 }
116 if( db_changes() ){
117 fossil_print("ADDED %s\n", zPath);
118 return 1;
119
--- src/add.c
+++ src/add.c
@@ -106,13 +106,13 @@
106 db_multi_exec("UPDATE vfile SET deleted=0"
107 " WHERE pathname=%Q COLLATE %s", zPath, zCollate);
108 }else{
109 char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath);
110 db_multi_exec(
111 "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe,islink)"
112 "VALUES(%d,0,0,0,%Q,%d,%d)",
113 vid, zPath, file_isexe(zFullname), file_islink(zFullname));
114 fossil_free(zFullname);
115 }
116 if( db_changes() ){
117 fossil_print("ADDED %s\n", zPath);
118 return 1;
119
+10 -2
--- src/export.c
+++ src/export.c
@@ -269,12 +269,20 @@
269269
const char *zName = db_column_text(&q4,0);
270270
int zNew = db_column_int(&q4,1);
271271
int mPerm = db_column_int(&q4,2);
272272
if( zNew==0)
273273
printf("D %s\n", zName);
274
- else if( bag_find(&blobs, zNew) )
275
- printf("M %s :%d %s\n", mPerm ? "100755" : "100644", BLOBMARK(zNew), zName);
274
+ else if( bag_find(&blobs, zNew) ) {
275
+ const char *zPerm;
276
+ if( mPerm==1 )
277
+ zPerm = "100755";
278
+ else if( mPerm==2 )
279
+ zPerm = "120000";
280
+ else
281
+ zPerm = "100644";
282
+ printf("M %s :%d %s\n", zPerm, BLOBMARK(zNew), zName);
283
+ }
276284
}
277285
db_finalize(&q4);
278286
db_finalize(&q3);
279287
printf("\n");
280288
}
281289
--- src/export.c
+++ src/export.c
@@ -269,12 +269,20 @@
269 const char *zName = db_column_text(&q4,0);
270 int zNew = db_column_int(&q4,1);
271 int mPerm = db_column_int(&q4,2);
272 if( zNew==0)
273 printf("D %s\n", zName);
274 else if( bag_find(&blobs, zNew) )
275 printf("M %s :%d %s\n", mPerm ? "100755" : "100644", BLOBMARK(zNew), zName);
 
 
 
 
 
 
 
 
276 }
277 db_finalize(&q4);
278 db_finalize(&q3);
279 printf("\n");
280 }
281
--- src/export.c
+++ src/export.c
@@ -269,12 +269,20 @@
269 const char *zName = db_column_text(&q4,0);
270 int zNew = db_column_int(&q4,1);
271 int mPerm = db_column_int(&q4,2);
272 if( zNew==0)
273 printf("D %s\n", zName);
274 else if( bag_find(&blobs, zNew) ) {
275 const char *zPerm;
276 if( mPerm==1 )
277 zPerm = "100755";
278 else if( mPerm==2 )
279 zPerm = "120000";
280 else
281 zPerm = "100644";
282 printf("M %s :%d %s\n", zPerm, BLOBMARK(zNew), zName);
283 }
284 }
285 db_finalize(&q4);
286 db_finalize(&q3);
287 printf("\n");
288 }
289
+15
--- src/file.c
+++ src/file.c
@@ -197,10 +197,25 @@
197197
#else
198198
return ((S_IXUSR|S_IXGRP|S_IXOTH)&fileStat.st_mode)!=0;
199199
#endif
200200
}
201201
202
+
203
+/*
204
+** Return file "permissions":
205
+** 0: normal
206
+** 1: exec
207
+** 2: symlink
208
+*/
209
+int file_perm(const char *zFilename){
210
+ //TODO(dchest): optimize by calling stat once.
211
+ if( file_isexe(zFilename) )
212
+ return 1;
213
+ if( file_islink(zFilename) )
214
+ return 2;
215
+ return 0;
216
+}
202217
203218
/*
204219
** Return 1 if zFilename is a directory. Return 0 if zFilename
205220
** does not exist. Return 2 if zFilename exists but is something
206221
** other than a directory.
207222
--- src/file.c
+++ src/file.c
@@ -197,10 +197,25 @@
197 #else
198 return ((S_IXUSR|S_IXGRP|S_IXOTH)&fileStat.st_mode)!=0;
199 #endif
200 }
201
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
203 /*
204 ** Return 1 if zFilename is a directory. Return 0 if zFilename
205 ** does not exist. Return 2 if zFilename exists but is something
206 ** other than a directory.
207
--- src/file.c
+++ src/file.c
@@ -197,10 +197,25 @@
197 #else
198 return ((S_IXUSR|S_IXGRP|S_IXOTH)&fileStat.st_mode)!=0;
199 #endif
200 }
201
202
203 /*
204 ** Return file "permissions":
205 ** 0: normal
206 ** 1: exec
207 ** 2: symlink
208 */
209 int file_perm(const char *zFilename){
210 //TODO(dchest): optimize by calling stat once.
211 if( file_isexe(zFilename) )
212 return 1;
213 if( file_islink(zFilename) )
214 return 2;
215 return 0;
216 }
217
218 /*
219 ** Return 1 if zFilename is a directory. Return 0 if zFilename
220 ** does not exist. Return 2 if zFilename exists but is something
221 ** other than a directory.
222
+3 -3
--- src/info.c
+++ src/info.c
@@ -282,21 +282,21 @@
282282
const char *zName, /* Name of the file that has changed */
283283
const char *zOld, /* blob.uuid before change. NULL for added files */
284284
const char *zNew, /* blob.uuid after change. NULL for deletes */
285285
const char *zOldName, /* Prior name. NULL if no name change. */
286286
int showDiff, /* Show edit diffs if true */
287
- int mperm /* EXE permission for zNew */
287
+ int mperm /* executable or symlink permission for zNew */
288288
){
289289
if( !g.okHistory ){
290290
if( zNew==0 ){
291291
@ <p>Deleted %h(zName)</p>
292292
}else if( zOld==0 ){
293293
@ <p>Added %h(zName)</p>
294294
}else if( zOldName!=0 && fossil_strcmp(zName,zOldName)!=0 ){
295295
@ <p>Name change from %h(zOldName) to %h(zName)
296296
}else if( fossil_strcmp(zNew, zOld)==0 ){
297
- @ <p>Execute permission %s(mperm?"set":"cleared") for %h(zName)</p>
297
+ @ <p>Execute permission %s(( mperm==1 )?"set":"cleared") for %h(zName)</p>
298298
}else{
299299
@ <p>Changes to %h(zName)</p>
300300
}
301301
if( showDiff ){
302302
@ <blockquote><pre>
@@ -312,11 +312,11 @@
312312
}else if( zOldName!=0 && fossil_strcmp(zName,zOldName)!=0 ){
313313
@ <p>Name change from
314314
@ from <a href="%s(g.zTop)/finfo?name=%T(zOldName)">%h(zOldName)</a>
315315
@ to <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>.
316316
}else{
317
- @ <p>Execute permission %s(mperm?"set":"cleared") for
317
+ @ <p>Execute permission %s(( mperm==1 )?"set":"cleared") for
318318
@ <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
319319
}
320320
}else if( zOld ){
321321
@ <p>Deleted <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
322322
@ version <a href="%s(g.zTop)/artifact/%s(zOld)">[%S(zOld)]</a>
323323
--- src/info.c
+++ src/info.c
@@ -282,21 +282,21 @@
282 const char *zName, /* Name of the file that has changed */
283 const char *zOld, /* blob.uuid before change. NULL for added files */
284 const char *zNew, /* blob.uuid after change. NULL for deletes */
285 const char *zOldName, /* Prior name. NULL if no name change. */
286 int showDiff, /* Show edit diffs if true */
287 int mperm /* EXE permission for zNew */
288 ){
289 if( !g.okHistory ){
290 if( zNew==0 ){
291 @ <p>Deleted %h(zName)</p>
292 }else if( zOld==0 ){
293 @ <p>Added %h(zName)</p>
294 }else if( zOldName!=0 && fossil_strcmp(zName,zOldName)!=0 ){
295 @ <p>Name change from %h(zOldName) to %h(zName)
296 }else if( fossil_strcmp(zNew, zOld)==0 ){
297 @ <p>Execute permission %s(mperm?"set":"cleared") for %h(zName)</p>
298 }else{
299 @ <p>Changes to %h(zName)</p>
300 }
301 if( showDiff ){
302 @ <blockquote><pre>
@@ -312,11 +312,11 @@
312 }else if( zOldName!=0 && fossil_strcmp(zName,zOldName)!=0 ){
313 @ <p>Name change from
314 @ from <a href="%s(g.zTop)/finfo?name=%T(zOldName)">%h(zOldName)</a>
315 @ to <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>.
316 }else{
317 @ <p>Execute permission %s(mperm?"set":"cleared") for
318 @ <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
319 }
320 }else if( zOld ){
321 @ <p>Deleted <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
322 @ version <a href="%s(g.zTop)/artifact/%s(zOld)">[%S(zOld)]</a>
323
--- src/info.c
+++ src/info.c
@@ -282,21 +282,21 @@
282 const char *zName, /* Name of the file that has changed */
283 const char *zOld, /* blob.uuid before change. NULL for added files */
284 const char *zNew, /* blob.uuid after change. NULL for deletes */
285 const char *zOldName, /* Prior name. NULL if no name change. */
286 int showDiff, /* Show edit diffs if true */
287 int mperm /* executable or symlink permission for zNew */
288 ){
289 if( !g.okHistory ){
290 if( zNew==0 ){
291 @ <p>Deleted %h(zName)</p>
292 }else if( zOld==0 ){
293 @ <p>Added %h(zName)</p>
294 }else if( zOldName!=0 && fossil_strcmp(zName,zOldName)!=0 ){
295 @ <p>Name change from %h(zOldName) to %h(zName)
296 }else if( fossil_strcmp(zNew, zOld)==0 ){
297 @ <p>Execute permission %s(( mperm==1 )?"set":"cleared") for %h(zName)</p>
298 }else{
299 @ <p>Changes to %h(zName)</p>
300 }
301 if( showDiff ){
302 @ <blockquote><pre>
@@ -312,11 +312,11 @@
312 }else if( zOldName!=0 && fossil_strcmp(zName,zOldName)!=0 ){
313 @ <p>Name change from
314 @ from <a href="%s(g.zTop)/finfo?name=%T(zOldName)">%h(zOldName)</a>
315 @ to <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>.
316 }else{
317 @ <p>Execute permission %s(( mperm==1 )?"set":"cleared") for
318 @ <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
319 }
320 }else if( zOld ){
321 @ <p>Deleted <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
322 @ version <a href="%s(g.zTop)/artifact/%s(zOld)">[%S(zOld)]</a>
323
+6 -3
--- src/manifest.c
+++ src/manifest.c
@@ -1086,12 +1086,15 @@
10861086
** Compute an appropriate mlink.mperm integer for the permission string
10871087
** of a file.
10881088
*/
10891089
int manifest_file_mperm(ManifestFile *pFile){
10901090
int mperm = 0;
1091
- if( pFile && pFile->zPerm && strstr(pFile->zPerm,"x")!=0 ){
1092
- mperm = 1;
1091
+ if( pFile && pFile->zPerm){
1092
+ if( strstr(pFile->zPerm,"x")!=0 )
1093
+ mperm = 1;
1094
+ else if( strstr(pFile->zPerm,"l")!=0 )
1095
+ mperm = 2;
10931096
}
10941097
return mperm;
10951098
}
10961099
10971100
/*
@@ -1103,11 +1106,11 @@
11031106
const char *zFromUuid, /* UUID for the mlink.pid. "" to add file */
11041107
const char *zToUuid, /* UUID for the mlink.fid. "" to delele */
11051108
const char *zFilename, /* Filename */
11061109
const char *zPrior, /* Previous filename. NULL if unchanged */
11071110
int isPublic, /* True if mid is not a private manifest */
1108
- int mperm /* 1: exec */
1111
+ int mperm /* 1: exec, 2: symlink */
11091112
){
11101113
int fnid, pfnid, pid, fid;
11111114
static Stmt s1;
11121115
11131116
fnid = filename_to_fnid(zFilename);
11141117
--- src/manifest.c
+++ src/manifest.c
@@ -1086,12 +1086,15 @@
1086 ** Compute an appropriate mlink.mperm integer for the permission string
1087 ** of a file.
1088 */
1089 int manifest_file_mperm(ManifestFile *pFile){
1090 int mperm = 0;
1091 if( pFile && pFile->zPerm && strstr(pFile->zPerm,"x")!=0 ){
1092 mperm = 1;
 
 
 
1093 }
1094 return mperm;
1095 }
1096
1097 /*
@@ -1103,11 +1106,11 @@
1103 const char *zFromUuid, /* UUID for the mlink.pid. "" to add file */
1104 const char *zToUuid, /* UUID for the mlink.fid. "" to delele */
1105 const char *zFilename, /* Filename */
1106 const char *zPrior, /* Previous filename. NULL if unchanged */
1107 int isPublic, /* True if mid is not a private manifest */
1108 int mperm /* 1: exec */
1109 ){
1110 int fnid, pfnid, pid, fid;
1111 static Stmt s1;
1112
1113 fnid = filename_to_fnid(zFilename);
1114
--- src/manifest.c
+++ src/manifest.c
@@ -1086,12 +1086,15 @@
1086 ** Compute an appropriate mlink.mperm integer for the permission string
1087 ** of a file.
1088 */
1089 int manifest_file_mperm(ManifestFile *pFile){
1090 int mperm = 0;
1091 if( pFile && pFile->zPerm){
1092 if( strstr(pFile->zPerm,"x")!=0 )
1093 mperm = 1;
1094 else if( strstr(pFile->zPerm,"l")!=0 )
1095 mperm = 2;
1096 }
1097 return mperm;
1098 }
1099
1100 /*
@@ -1103,11 +1106,11 @@
1106 const char *zFromUuid, /* UUID for the mlink.pid. "" to add file */
1107 const char *zToUuid, /* UUID for the mlink.fid. "" to delele */
1108 const char *zFilename, /* Filename */
1109 const char *zPrior, /* Previous filename. NULL if unchanged */
1110 int isPublic, /* True if mid is not a private manifest */
1111 int mperm /* 1: exec, 2: symlink */
1112 ){
1113 int fnid, pfnid, pid, fid;
1114 static Stmt s1;
1115
1116 fnid = filename_to_fnid(zFilename);
1117
+2 -5
--- src/update.c
+++ src/update.c
@@ -568,15 +568,12 @@
568568
569569
if( pManifest ){
570570
pFile = manifest_file_seek(pManifest, file);
571571
if( pFile ){
572572
rid = uuid_to_rid(pFile->zUuid, 0);
573
- if( pIsExe ) *pIsExe = manifest_file_mperm(pFile);
574
- if( pIsLink ){
575
- //TODO(dchest): figure out how to fit manifest_file_mperm.
576
- *pIsLink = pFile->zPerm && strstr(pFile->zPerm, "l") ? 1 : 0;
577
- }
573
+ if( pIsExe ) *pIsExe = ( manifest_file_mperm(pFile)==1 );
574
+ if( pIsLink ) *pIsLink = ( manifest_file_mperm(pFile)==2 );
578575
manifest_destroy(pManifest);
579576
return content_get(rid, content);
580577
}
581578
manifest_destroy(pManifest);
582579
if( errCode<=0 ){
583580
--- src/update.c
+++ src/update.c
@@ -568,15 +568,12 @@
568
569 if( pManifest ){
570 pFile = manifest_file_seek(pManifest, file);
571 if( pFile ){
572 rid = uuid_to_rid(pFile->zUuid, 0);
573 if( pIsExe ) *pIsExe = manifest_file_mperm(pFile);
574 if( pIsLink ){
575 //TODO(dchest): figure out how to fit manifest_file_mperm.
576 *pIsLink = pFile->zPerm && strstr(pFile->zPerm, "l") ? 1 : 0;
577 }
578 manifest_destroy(pManifest);
579 return content_get(rid, content);
580 }
581 manifest_destroy(pManifest);
582 if( errCode<=0 ){
583
--- src/update.c
+++ src/update.c
@@ -568,15 +568,12 @@
568
569 if( pManifest ){
570 pFile = manifest_file_seek(pManifest, file);
571 if( pFile ){
572 rid = uuid_to_rid(pFile->zUuid, 0);
573 if( pIsExe ) *pIsExe = ( manifest_file_mperm(pFile)==1 );
574 if( pIsLink ) *pIsLink = ( manifest_file_mperm(pFile)==2 );
 
 
 
575 manifest_destroy(pManifest);
576 return content_get(rid, content);
577 }
578 manifest_destroy(pManifest);
579 if( errCode<=0 ){
580
+2 -3
--- src/vfile.c
+++ src/vfile.c
@@ -110,15 +110,14 @@
110110
db_reset(&ridq);
111111
if( rid==0 || size<0 ){
112112
fossil_warning("content missing for %s", pFile->zName);
113113
continue;
114114
}
115
- db_bind_int(&ins, ":isexe", manifest_file_mperm(pFile));
115
+ db_bind_int(&ins, ":isexe", ( manifest_file_mperm(pFile)==1 ));
116116
db_bind_int(&ins, ":id", rid);
117117
db_bind_text(&ins, ":name", pFile->zName);
118
- //TODO(dchest) figure out how to fit manifest_file_mperm here:
119
- db_bind_int(&ins, ":islink", pFile->zPerm && strstr(pFile->zPerm, "l"));
118
+ db_bind_int(&ins, ":islink", ( manifest_file_mperm(pFile)==2 ));
120119
db_step(&ins);
121120
db_reset(&ins);
122121
}
123122
db_finalize(&ridq);
124123
db_finalize(&ins);
125124
--- src/vfile.c
+++ src/vfile.c
@@ -110,15 +110,14 @@
110 db_reset(&ridq);
111 if( rid==0 || size<0 ){
112 fossil_warning("content missing for %s", pFile->zName);
113 continue;
114 }
115 db_bind_int(&ins, ":isexe", manifest_file_mperm(pFile));
116 db_bind_int(&ins, ":id", rid);
117 db_bind_text(&ins, ":name", pFile->zName);
118 //TODO(dchest) figure out how to fit manifest_file_mperm here:
119 db_bind_int(&ins, ":islink", pFile->zPerm && strstr(pFile->zPerm, "l"));
120 db_step(&ins);
121 db_reset(&ins);
122 }
123 db_finalize(&ridq);
124 db_finalize(&ins);
125
--- src/vfile.c
+++ src/vfile.c
@@ -110,15 +110,14 @@
110 db_reset(&ridq);
111 if( rid==0 || size<0 ){
112 fossil_warning("content missing for %s", pFile->zName);
113 continue;
114 }
115 db_bind_int(&ins, ":isexe", ( manifest_file_mperm(pFile)==1 ));
116 db_bind_int(&ins, ":id", rid);
117 db_bind_text(&ins, ":name", pFile->zName);
118 db_bind_int(&ins, ":islink", ( manifest_file_mperm(pFile)==2 ));
 
119 db_step(&ins);
120 db_reset(&ins);
121 }
122 db_finalize(&ridq);
123 db_finalize(&ins);
124
+3 -3
--- src/zip.c
+++ src/zip.c
@@ -117,11 +117,11 @@
117117
** Append a single file to a growing ZIP archive.
118118
**
119119
** pFile is the file to be appended. zName is the name
120120
** that the file should be saved as.
121121
*/
122
-void zip_add_file(const char *zName, const Blob *pFile, int isExe){
122
+void zip_add_file(const char *zName, const Blob *pFile, int mPerm){
123123
z_stream stream;
124124
int nameLen;
125125
int toOut = 0;
126126
int iStart;
127127
int iCRC = 0;
@@ -139,11 +139,11 @@
139139
/* Fill in as much of the header as we know.
140140
*/
141141
nBlob = pFile ? blob_size(pFile) : 0;
142142
if( nBlob>0 ){
143143
iMethod = 8;
144
- iMode = isExe ? 0100755 : 0100644;
144
+ iMode = ( mPerm == 1 ) ? 0100755 : 0100644; //TODO(dchest): handle links
145145
}else{
146146
iMethod = 0;
147147
iMode = 040755;
148148
}
149149
nameLen = strlen(zName);
@@ -287,11 +287,11 @@
287287
}
288288
zip_open();
289289
for(i=3; i<g.argc; i++){
290290
blob_zero(&file);
291291
blob_read_from_file(&file, g.argv[i]);
292
- zip_add_file(g.argv[i], &file, file_isexe(g.argv[i]));
292
+ zip_add_file(g.argv[i], &file, file_perm(g.argv[i]));
293293
blob_reset(&file);
294294
}
295295
zip_close(&zip);
296296
blob_write_to_file(&zip, g.argv[2]);
297297
}
298298
--- src/zip.c
+++ src/zip.c
@@ -117,11 +117,11 @@
117 ** Append a single file to a growing ZIP archive.
118 **
119 ** pFile is the file to be appended. zName is the name
120 ** that the file should be saved as.
121 */
122 void zip_add_file(const char *zName, const Blob *pFile, int isExe){
123 z_stream stream;
124 int nameLen;
125 int toOut = 0;
126 int iStart;
127 int iCRC = 0;
@@ -139,11 +139,11 @@
139 /* Fill in as much of the header as we know.
140 */
141 nBlob = pFile ? blob_size(pFile) : 0;
142 if( nBlob>0 ){
143 iMethod = 8;
144 iMode = isExe ? 0100755 : 0100644;
145 }else{
146 iMethod = 0;
147 iMode = 040755;
148 }
149 nameLen = strlen(zName);
@@ -287,11 +287,11 @@
287 }
288 zip_open();
289 for(i=3; i<g.argc; i++){
290 blob_zero(&file);
291 blob_read_from_file(&file, g.argv[i]);
292 zip_add_file(g.argv[i], &file, file_isexe(g.argv[i]));
293 blob_reset(&file);
294 }
295 zip_close(&zip);
296 blob_write_to_file(&zip, g.argv[2]);
297 }
298
--- src/zip.c
+++ src/zip.c
@@ -117,11 +117,11 @@
117 ** Append a single file to a growing ZIP archive.
118 **
119 ** pFile is the file to be appended. zName is the name
120 ** that the file should be saved as.
121 */
122 void zip_add_file(const char *zName, const Blob *pFile, int mPerm){
123 z_stream stream;
124 int nameLen;
125 int toOut = 0;
126 int iStart;
127 int iCRC = 0;
@@ -139,11 +139,11 @@
139 /* Fill in as much of the header as we know.
140 */
141 nBlob = pFile ? blob_size(pFile) : 0;
142 if( nBlob>0 ){
143 iMethod = 8;
144 iMode = ( mPerm == 1 ) ? 0100755 : 0100644; //TODO(dchest): handle links
145 }else{
146 iMethod = 0;
147 iMode = 040755;
148 }
149 nameLen = strlen(zName);
@@ -287,11 +287,11 @@
287 }
288 zip_open();
289 for(i=3; i<g.argc; i++){
290 blob_zero(&file);
291 blob_read_from_file(&file, g.argv[i]);
292 zip_add_file(g.argv[i], &file, file_perm(g.argv[i]));
293 blob_reset(&file);
294 }
295 zip_close(&zip);
296 blob_write_to_file(&zip, g.argv[2]);
297 }
298

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button