1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
11 * Copyright (C) 2006 Christi Alice Scarborough
13 * All files in this archive are subject to the GNU General Public License.
14 * See the file COPYING in the source tree root for full license agreement.
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
19 ****************************************************************************/
21 #include "installlog.h"
24 InstallLog::InstallLog(wxString logname
, bool CreateLog
)
29 if (! CreateLog
&& ! wxFileExists(logname
) ) return;
31 logfile
= new wxFileConfig(wxEmptyString
, wxEmptyString
, logname
);
36 wxLogWarning(_("Failed to create install log file: ") + logname
);
40 logfile
->SetPath(wxT("/InstallLog"));
41 if (logfile
->Exists(wxT("Version")) &&
42 logfile
->Read(wxT("Version"), 0l) != LOGFILE_VERSION
)
44 wxLogWarning(_("Logfile version mismatch: ") + logname
);
49 logfile
->Write(wxT("Version"), LOGFILE_VERSION
);
53 InstallLog::~InstallLog()
55 if (dirtyflag
) return;
60 unsigned int InstallLog::WriteFile(wxString filepath
, bool isDir
)
63 long installcount
= 0;
65 if (dirtyflag
) return true;
67 filepath
.Replace(PATH_SEP
, wxT("/") );
69 if (filepath
.GetChar(0) == '/')
70 filepath
= filepath
.Right(filepath
.Len() - 1);
72 logfile
->SetPath(wxT("/FilePaths"));
73 installcount
= logfile
->Read(filepath
, 0l);
77 filepath
.Append(wxT("/" DIRECTORY_KLUDGE
) ); // Needed for empty dirs
80 logfile
->Write(filepath
, ++installcount
);
85 unsigned int InstallLog::WriteFile(wxArrayString filepaths
)
88 unsigned int finalrc
= false;
91 if (dirtyflag
) return true;
93 for (i
= 0; i
< filepaths
.GetCount(); i
++);
95 if ( WriteFile(filepaths
[i
]) )
104 wxArrayString
* InstallLog::GetInstalledFiles()
106 wxString curdir
= wxT("");
108 if (dirtyflag
) return NULL
;
111 EnumerateCurDir(wxT(""));
113 wxArrayString
* out
= new wxArrayString(workingAS
);
117 void InstallLog::EnumerateCurDir(wxString curdir
)
120 wxString curname
, buf
, buf2
, pathcache
;
123 buf
= wxT("/FilePaths/") + curdir
;
124 pathcache
= logfile
->GetPath();
125 logfile
->SetPath(buf
);
127 contflag
= logfile
->GetFirstGroup(curname
, dummy
);
130 buf
= curdir
+ wxT("/") + curname
;
131 buf2
= buf
; buf2
.Replace(wxT("/"), PATH_SEP
);
133 EnumerateCurDir(buf
);
134 contflag
= logfile
->GetNextGroup(curname
, dummy
);
137 contflag
= logfile
->GetFirstEntry(curname
, dummy
);
140 if (curname
!= wxT(DIRECTORY_KLUDGE
) )
142 buf
= curdir
+ wxT("" PATH_SEP
) + curname
;
145 contflag
= logfile
->GetNextEntry(curname
, dummy
);
148 logfile
->SetPath(pathcache
);