1210 DavBool root, |
1210 DavBool root, |
1211 DavBool printfile, |
1211 DavBool printfile, |
1212 DavBool ignoredirerr) |
1212 DavBool ignoredirerr) |
1213 { |
1213 { |
1214 int recursive = cmd_getoption(a, "recursive") ? 1 : 0; |
1214 int recursive = cmd_getoption(a, "recursive") ? 1 : 0; |
1215 struct stat s; |
1215 SYS_STAT s; |
1216 if(stat(file, &s)) { |
1216 if(sys_stat(file, &s)) { |
1217 perror("stat"); |
1217 perror("stat"); |
1218 fprintf(stderr, "cannot stat file %s\n", file); |
1218 fprintf(stderr, "cannot stat file %s\n", file); |
1219 return -1; |
1219 return -1; |
1220 } |
1220 } |
1221 |
1221 |
1235 |
1235 |
1236 if(!root) { |
1236 if(!root) { |
1237 printf("mkcol: %s\n", file); |
1237 printf("mkcol: %s\n", file); |
1238 } |
1238 } |
1239 |
1239 |
1240 DIR *dir = opendir(file); |
1240 SYS_DIR dir = sys_opendir(file); |
1241 if(!dir) { |
1241 if(!dir) { |
1242 // error |
1242 // error |
1243 } |
1243 } |
1244 struct dirent *entry; |
1244 SysDirEnt *entry; |
1245 int nument = 0; |
1245 int nument = 0; |
1246 while((entry = readdir(dir)) != NULL) { |
1246 while((entry = sys_readdir(dir)) != NULL) { |
1247 if(!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) { |
1247 if(!strcmp(entry->name, ".") || !strcmp(entry->name, "..")) { |
1248 continue; |
1248 continue; |
1249 } |
1249 } |
1250 nument++; |
1250 nument++; |
1251 char *entry_file = util_concat_path(file, entry->d_name); |
1251 char *entry_file = util_concat_path(file, entry->name); |
1252 char *entry_path = util_concat_path(path, entry->d_name); |
1252 char *entry_path = util_concat_path(path, entry->name); |
1253 int r = put_entry( |
1253 int r = put_entry( |
1254 repo, |
1254 repo, |
1255 a, |
1255 a, |
1256 sn, |
1256 sn, |
1257 entry_path, |
1257 entry_path, |
1285 } else if(S_ISREG(s.st_mode)) { |
1285 } else if(S_ISREG(s.st_mode)) { |
1286 if(printfile) { |
1286 if(printfile) { |
1287 printf("put: %s\n", file); |
1287 printf("put: %s\n", file); |
1288 } |
1288 } |
1289 |
1289 |
1290 FILE *in = fopen(file, "rb"); |
1290 FILE *in = sys_fopen(file, "rb"); |
1291 if(!in) { |
1291 if(!in) { |
1292 fprintf(stderr, "cannot open input file\n"); |
1292 fprintf(stderr, "cannot open input file\n"); |
1293 return -1; |
1293 return -1; |
1294 } |
1294 } |
1295 char *filename = util_resource_name(file); |
1295 char *filename = util_resource_name(file); |