dav/main.c

changeset 739
bba6a6e221b4
parent 734
b2cd82149116
child 744
f0d7178043c1
equal deleted inserted replaced
738:b62ea7f31593 739:bba6a6e221b4
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,
1265 if(r) { 1265 if(r) {
1266 ret = 1; 1266 ret = 1;
1267 break; 1267 break;
1268 } 1268 }
1269 } 1269 }
1270 closedir(dir); 1270 sys_closedir(dir);
1271 1271
1272 if(nument == 0) { 1272 if(nument == 0) {
1273 // create empty directory 1273 // create empty directory
1274 DavResource *res = dav_resource_new(sn, path); 1274 DavResource *res = dav_resource_new(sn, path);
1275 res->iscollection = TRUE; 1275 res->iscollection = TRUE;
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);

mercurial