summaryrefslogtreecommitdiff
path: root/win/Libdlg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'win/Libdlg.cpp')
-rw-r--r--win/Libdlg.cpp244
1 files changed, 2 insertions, 242 deletions
diff --git a/win/Libdlg.cpp b/win/Libdlg.cpp
index cf5e0b1..23974b1 100644
--- a/win/Libdlg.cpp
+++ b/win/Libdlg.cpp
@@ -292,252 +292,12 @@ BOOL CLibraryDlg::OnCommand(WPARAM wParam, LPARAM lParam)
if (filedlg.DoModal() != IDOK)
return TRUE;
- CFile up;
- BYTE bt;
- if (!up.Open (filedlg.GetPathName(), CFile::modeRead | CFile::typeBinary))
- return TRUE;
-
- up.Seek(32, CFile::begin);
- up.Read(&bt, 1);
- if (bt != 2)
- {
- AfxMessageBox("Wrong version !", MB_ICONWARNING|MB_OK);
- return TRUE;
- }
-
-
-/*
- up.Read(&bt, 1); // update number
-
- CWaitCursor wc;
- char p[260];
- GetModuleFileName (AfxGetInstanceHandle(), (char*)&p, 260);
- if (char* ptr = strrchr (p,'\\')) *ptr = 0;
- CString app = p;
- app += "\\";
-
- DeleteFile(app + "PIECES-B.OLD");
- DeleteFile(app + "PIECES-I.OLD");
- MoveFile(app + "PIECES.BIN", app + "PIECES-B.OLD");
- MoveFile(app + "PIECES.IDX", app + "PIECES-I.OLD");
-
- CFile oldbin,oldidx,newbin,newidx;
- if ((!oldbin.Open (app + "PIECES-B.OLD", CFile::modeRead | CFile::typeBinary)) ||
- (!oldidx.Open (app + "PIECES-I.OLD", CFile::modeRead | CFile::typeBinary)) ||
- (!newbin.Open (app + "PIECES.BIN", CFile::modeCreate | CFile::modeWrite | CFile::typeBinary)) ||
- (!newidx.Open (app + "PIECES.IDX", CFile::modeCreate | CFile::modeWrite | CFile::typeBinary)))
- {
- AfxMessageBox("Cannot open file.", MB_OK|MB_ICONERROR);
- return TRUE;
- }
-
- char tmp[200];
- WORD changes, count, newcount = 0, i, j;
- up.Seek(-(LONG)sizeof(changes), CFile::end);
- up.Read(&changes, sizeof(changes));
- up.Seek(34, CFile::begin);
-
- oldidx.Seek (-(LONG)(sizeof(count)), CFile::end);
- oldidx.Read (&count, sizeof(count));
- oldidx.Seek (0, CFile::begin);
- oldidx.Read(tmp, 33);
- newidx.Write(tmp, 33);
- oldbin.Read(tmp, 33);
- newbin.Write(tmp, 33);
-
- typedef struct {
- char name[9];
- BYTE type;
- DWORD offset;
- } UPDATE_INFO;
-
- #define UPDATE_DELETE 0x00
- #define UPDATE_DESCRIPTION 0x01
- #define UPDATE_DRAWINFO 0x02
- #define UPDATE_NEWPIECE 0x04
-
- UPDATE_INFO* upinfo = (UPDATE_INFO*)malloc(sizeof(UPDATE_INFO)*changes);
- memset(upinfo, 0, sizeof(UPDATE_INFO)*changes);
-
- DWORD nextoff, binoff, cs;
- for (i = 0; i < changes; i++)
- {
- up.Read(&upinfo[i].name, 8);
- up.Read(&upinfo[i].type, 1);
- upinfo[i].offset = up.GetPosition();
-
- if ((upinfo[i].type & UPDATE_DESCRIPTION) ||
- (upinfo[i].type & UPDATE_NEWPIECE))
- up.Seek(64, CFile::current);
-
- if ((upinfo[i].type & UPDATE_DRAWINFO) ||
- (upinfo[i].type & UPDATE_NEWPIECE))
- {
- up.Seek(sizeof(short[6]), CFile::current);
- up.Read(&cs, sizeof(cs));
- up.Seek(cs, CFile::current);
- }
- }
-
- CProgressDlg dlg(_T("Updating Library"));
- dlg.Create(this);
- dlg.SetRange (0, count);
-
- void* membuf;
- for (i = 0; i < count; i++)
- {
- char name[9];
- name[8] = 0;
- oldidx.Read (&name, 8);
-
- dlg.StepIt();
- if(dlg.CheckCancelButton())
- if(AfxMessageBox(IDS_CANCEL_PROMPT, MB_YESNO) == IDYES)
- {
- free(upinfo);
- return TRUE;
- }
-
- for (j = 0; j < changes; j++)
- if (strcmp(name, upinfo[j].name) == 0)
- {
- if (upinfo[j].type == UPDATE_DELETE)
- {
- oldidx.Seek(64+sizeof(short[6])+sizeof(DWORD), CFile::current);
- break;
- }
- newcount++;
- up.Seek(upinfo[j].offset, CFile::begin);
- newidx.Write(name, 8);
-
- if (upinfo[j].type & UPDATE_DESCRIPTION)
- {
- up.Read(&tmp, 64);
- oldidx.Seek(64, CFile::current);
- }
- else
- oldidx.Read(&tmp, 64);
- newidx.Write(tmp, 64);
- dlg.SetStatus(tmp);
-
- if (upinfo[j].type & UPDATE_DRAWINFO)
- {
- up.Read(&tmp, sizeof(short[6]));
- oldidx.Seek(sizeof(short[6]), CFile::current);
- }
- else
- oldidx.Read(&tmp, sizeof(short[6]));
- newidx.Write(tmp, sizeof(short[6]));
- binoff = newbin.GetLength();
- newidx.Write(&binoff, sizeof(binoff));
-
- if (upinfo[j].type & UPDATE_DRAWINFO)
- {
- up.Read(&cs, sizeof(cs));
- oldidx.Seek(sizeof(binoff), CFile::current);
-
- membuf = malloc(cs);
- up.Read(membuf, cs);
- newbin.Write(membuf, cs);
- free (membuf);
- }
- else
- {
- oldidx.Read(&binoff, sizeof(binoff));
-
- if (i == count-1)
- nextoff = oldbin.GetLength();
- else
- {
- oldidx.Seek(72+sizeof(short[6]), CFile::current);
- oldidx.Read(&nextoff, sizeof(nextoff));
- oldidx.Seek(-(LONG)(72+sizeof(short[6])+sizeof(DWORD)), CFile::current);
- }
-
- membuf = malloc (nextoff - binoff);
- oldbin.Seek(binoff, CFile::begin);
- oldbin.Read(membuf, nextoff - binoff);
- newbin.Write(membuf, nextoff - binoff);
- free (membuf);
- }
- break;
- }
-
- // not changed, just copy
- if (j == changes)
- {
- newcount++;
- newidx.Write(name, 8);
- oldidx.Read(tmp, 64+sizeof(short[6]));
- newidx.Write(tmp, 64+sizeof(short[6]));
- binoff = newbin.GetLength();
- newidx.Write(&binoff, sizeof(binoff));
- oldidx.Read(&binoff, sizeof(binoff));
-
- tmp[64] = 0;
- dlg.SetStatus(tmp);
-
- if (i == count-1)
- nextoff = oldbin.GetLength();
- else
- {
- oldidx.Seek(72+sizeof(short[6]), CFile::current);
- oldidx.Read(&nextoff, sizeof(nextoff));
- oldidx.Seek(-(LONG)(72+sizeof(short[6])+sizeof(DWORD)), CFile::current);
- }
-
- membuf = malloc (nextoff - binoff);
- oldbin.Seek(binoff, CFile::begin);
- oldbin.Read(membuf, nextoff - binoff);
- newbin.Write(membuf, nextoff - binoff);
- free (membuf);
- }
- }
-
- // now add new pieces
- for (j = 0; j < changes; j++)
- if (upinfo[j].type == UPDATE_NEWPIECE)
- {
- newcount++;
- newidx.Write(upinfo[j].name, 8);
- up.Seek(upinfo[j].offset, CFile::begin);
- up.Read(&tmp, 64+sizeof(short[6]));
- newidx.Write(tmp, 64+sizeof(short[6]));
- binoff = newbin.GetLength();
- newidx.Write(&binoff, sizeof(binoff));
-
- up.Read(&cs, sizeof(cs));
- membuf = malloc(cs);
- up.Read(membuf, cs);
- newbin.Write(membuf, cs);
- free (membuf);
- }
-
- WORD moved;
- up.Seek(-(LONG)(sizeof(WORD)*2), CFile::end);
- up.Read(&moved, sizeof(WORD));
- cs = sizeof(WORD)+moved*16;
- up.Seek(-(LONG)(cs), CFile::current);
- membuf = malloc(cs);
- up.Read(membuf, cs);
- newidx.Write(membuf, cs);
- free (membuf);
-
- nextoff = newbin.GetLength();
- newidx.Write(&nextoff, sizeof(DWORD));
- newidx.Write(&newcount, sizeof(WORD));
-
- free(upinfo);
- oldidx.Close();
- oldbin.Close();
- newidx.Close();
- newbin.Close();
- up.Close();
+ LoadUpdate(filedlg.GetPathName());
// update m_Parts
UpdateList();
m_bReload = TRUE;
-*/
+
return TRUE;
}