| 1065 | } |
| 1066 | |
| 1067 | void createconfigtemplates(const char *templatezip) // create customisable config files in homedir - only if missing |
| 1068 | { |
| 1069 | vector<const char *> files; |
| 1070 | void *mz = zipmanualopen(openfile(templatezip, "rb"), files); |
| 1071 | if(mz) |
| 1072 | { |
| 1073 | loopv(files) |
| 1074 | { |
| 1075 | const char *filename = behindpath(files[i]); // only look for config files in the zip file, ignore all paths in the zip |
| 1076 | if(strlen(filename) > 4 && !strcmp(filename + strlen(filename) - 4, ".cfg")) |
| 1077 | { |
| 1078 | defformatstring(fname)("config" PATHDIVS "%s", files[i]); |
| 1079 | if(getfilesize(fname) <= 0) // config does not exist or is empty |
| 1080 | { |
| 1081 | stream *zf = openfile(fname, "wb"); |
| 1082 | if(zf) |
| 1083 | { |
| 1084 | zipmanualread(mz, i, zf, MAXCFGFILESIZE); // fetch file content from zip, write to new config file |
| 1085 | delete zf; |
| 1086 | conoutf("created %s from template %s", fname, templatezip); |
| 1087 | } |
| 1088 | } |
| 1089 | } |
| 1090 | } |
| 1091 | zipmanualclose(mz); |
| 1092 | } |
| 1093 | findfile(AUTOSTARTPATH "dummy", "w"); // create empty autostart directory, if it doesn't exist yet |
| 1094 | } |
| 1095 | |
| 1096 | void connectprotocol(char *protocolstring) // assaultcube://example.org[:28763][/][?[port=28763][&password=secret]] |
| 1097 | { |
no test coverage detected