HWND progress;
HINSTANCE hInst;
FILE* finst;
+char* config;
HFONT titlefont;
HFONT normalfont;
HFONT versionfont;
char welcome[512];
BOOL change = FALSE;
+BOOL dirchange = TRUE;
BOOL err;
HWND windows[512];
int window_count = 0;
char* name;
uint32_t size;
BOOL dir;
+ BOOL skip;
};
struct entry entries[2048];
sprintf(destpath, "%s%s", instpath, entries[i].name);
retry:
fseek(finst, strlen(entries[i].name), SEEK_CUR);
- if(entries[i].dir){
+ if(entries[i].skip){
+ fseek(finst, entries[i].size, SEEK_CUR);
+ fseek(finst, 4, SEEK_CUR);
+ fseek(finst, 1, SEEK_CUR);
+ }else if(entries[i].dir){
fseek(finst, 4, SEEK_CUR);
fseek(finst, 1, SEEK_CUR);
CreateDirectory(destpath, NULL);
if(gphase == PHASE_DIR){
SendMessage(edit, WM_GETTEXT, MAX_PATH, (LPARAM)instpath);
}
- gphase++;
+ if(gphase == PHASE_WELCOME){
+ if(dirchange){
+ gphase++;
+ }else{
+ gphase += 2;
+ }
+ }else{
+ gphase++;
+ }
RenderPhase(gphase, hWnd);
RedrawWindow(hWnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE);
}
uint32_t entbytes;
uint32_t incr;
BOOL first = TRUE;
+ config = NULL;
instpath[0] = 'C';
instpath[1] = ':';
instpath[2] = '\\';
entbytes |= n;
}
fflush(stdout);
- if(attr & 1){
+ if(attr == 1){
fseek(finst, -4-entbytes-1, SEEK_CUR);
fread(&fnlen, 1, 1, finst);
fseek(finst, -1-fnlen, SEEK_CUR);
}else{
int i;
entries[counts - incr - 1].dir = FALSE;
+ entries[counts - incr - 1].skip = FALSE;
entries[counts - incr - 1].name = fnnam;
entries[counts - incr - 1].size = entbytes;
for(i = 0; fnnam[i] != 0; i++){
}
incr++;
}
- }else{
+ }else if(attr == 0){
fnnam = malloc(entbytes + 1);
fnnam[entbytes] = 0;
fseek(finst, -4-entbytes, SEEK_CUR);
free(fnnam);
}else{
entries[counts - incr - 1].dir = TRUE;
+ entries[counts - incr - 1].skip = FALSE;
entries[counts - incr - 1].name = fnnam;
for(i = 0; fnnam[i] != 0; i++){
if(fnnam[i] == '/') fnnam[i] = '\\';
}
incr++;
}
+ }else if(attr == 2){
+ config = malloc(entbytes + 1);
+ config[entbytes] = 0;
+ fseek(finst, -4-entbytes, SEEK_CUR);
+ fread(config, 1, entbytes, finst);
+ fseek(finst, -entbytes, SEEK_CUR);
+ bytes -= entbytes + 4 + 1;
+
+ if(first){
+ free(config);
+ }else{
+ entries[counts - incr - 1].skip = TRUE;
+ entries[counts - incr - 1].size = entbytes;
+ entries[counts - incr - 1].name = "";
+ incr++;
+ }
}
if(first){
counts++;
goto loop;
}
+ if(config != NULL){
+ int i;
+ int incr = 0;
+ for(i = 0;; i++){
+ if(config[i] == '\n' || config[i] == 0){
+ char oldc = config[i];
+ char* line = config + incr;
+ config[i] = 0;
+
+ if(strlen(line) > 0 && line[0] != '#'){
+ int j;
+ for(j = 0;; j++){
+ if(line[j] == ' ' || line[j] == '\t' || line[j] == 0){
+ BOOL hasarg = line[j] != 0;
+ char* arg = NULL;
+ char oldc2 = line[j];
+ line[j] = 0;
+ if(hasarg){
+ j++;
+ for(; line[j] != 0 && (line[j] == '\t' || line[j] == ' '); j++);
+ arg = line + j;
+ }
+ if(strcmp(line, "DefaultDirectory") == 0 && hasarg){
+ strcpy(instpath, arg);
+ instpath[strlen(arg)] = 0;
+ }else if(strcmp(line, "DirectoryUnchangable") == 0){
+ dirchange = FALSE;
+ }
+ line[j] = oldc2;
+ break;
+ }
+ }
+ }
+
+ config[i] = oldc;
+ incr = i + 1;
+ if(oldc == 0) break;
+ }
+ }
+ }
+
strcpy(setupname, name);
strcpy(setupname + strlen(name), " Setup");
setupname[strlen(name) + 6] = 0;
#include <dirent.h>
#include <sys/stat.h>
#include <stdint.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <zlib.h>
#define COMPRESS 65535
+int scan(FILE* f, const char* base, const char* pref);
+
FILE* prepare_file(const char* path){
FILE* f = fopen(path, "wb");
if(f != NULL){
return f;
}
+void read_config(FILE* f, char* config){
+ int i;
+ int incr = 0;
+ for(i = 0;; i++){
+ if(config[i] == '\n' || config[i] == 0){
+ char oldc = config[i];
+ char* line = config + incr;
+ config[i] = 0;
+
+ if(strlen(line) > 0 && line[0] != '#'){
+ int j;
+ for(j = 0;; j++){
+ if(line[j] == ' ' || line[j] == '\t' || line[j] == 0){
+ bool hasarg = line[j] != 0;
+ char* arg = NULL;
+ line[j] = 0;
+ if(hasarg){
+ j++;
+ for(; line[j] != 0 && (line[j] == '\t' || line[j] == ' '); j++);
+ arg = line + j;
+ }
+ if(strcmp(line, "Include") == 0 && hasarg){
+ scan(f, arg, "");
+ }
+ break;
+ }
+ }
+ }
+
+ config[i] = oldc;
+ incr = i + 1;
+ if(oldc == 0) break;
+ }
+ }
+}
+
int scan(FILE* f, const char* base, const char* pref){
DIR* dir = opendir(base);
if(dir != NULL){
fprintf(stderr, "Failed to create one\n");
return 1;
}
- if(scan(f, input, "") != 0){
- fprintf(stderr, "Failed to process\n");
- fclose(f);
- remove(output);
- return 1;
+ if(input[0] == '@'){
+ struct stat s;
+ if(stat(input + 1, &s) == 0){
+ uint8_t byt;
+ uint32_t written = s.st_size;
+ char* buf;
+ FILE* fin = fopen(input + 1, "r");
+ buf = malloc(s.st_size + 1);
+ buf[s.st_size] = 0;
+ fread(buf, 1, s.st_size, fin);
+ fwrite(buf, 1, s.st_size, f);
+
+ fclose(fin);
+ for(i = 0; i < 4; i++){
+ byt = (written & 0xff000000) >> 24;
+ written = written << 8;
+ fwrite(&byt, 1, 1, f);
+ }
+ byt = 2;
+ fwrite(&byt, 1, 1, f);
+ total += s.st_size + 4 + 1;
+
+ read_config(f, buf);
+ }else{
+ fprintf(stderr, "Failed to process\n");
+ remove(output);
+ return 1;
+ }
+ }else{
+ if(scan(f, input, "") != 0){
+ fprintf(stderr, "Failed to process\n");
+ fclose(f);
+ remove(output);
+ return 1;
+ }
}
printf("Total: %lu bytes\n", (unsigned long)total);
strcpy(name, projname);