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 buf
.Printf(_("Failed to create install log file: %s"), logname
.c_str());
41 logfile
->SetPath("/InstallLog");
42 if (logfile
->Exists("Version") &&
43 logfile
->Read("Version", 0l) != LOGFILE_VERSION
)
45 buf
.Printf(_("Logfile version mismatch: %s"), logname
.c_str() );
51 logfile
->Write("Version", LOGFILE_VERSION
);
55 InstallLog::~InstallLog()
57 if (dirtyflag
) return;
62 unsigned int InstallLog::WriteFile(wxString filepath
, bool isDir
)
65 long installcount
= 0;
67 if (dirtyflag
) return true;
69 filepath
.Replace(PATH_SEP
, wxT("/") );
71 if (filepath
.GetChar(0) == '/')
72 filepath
= filepath
.Right(filepath
.Len() - 1);
74 logfile
->SetPath(wxT("/FilePaths"));
75 installcount
= logfile
->Read(filepath
, 0l);
79 filepath
.Append(wxT("/" DIRECTORY_KLUDGE
) ); // Needed for empty dirs
82 logfile
->Write(filepath
, ++installcount
);
87 unsigned int InstallLog::WriteFile(wxArrayString filepaths
)
90 unsigned int finalrc
= false;
93 if (dirtyflag
) return true;
95 for (i
= 0; i
< filepaths
.GetCount(); i
++);
97 if ( WriteFile(filepaths
[i
]) )
106 wxArrayString
* InstallLog::GetInstalledFiles()
108 wxString curdir
= "";
110 if (dirtyflag
) return NULL
;
115 wxArrayString
* out
= new wxArrayString(workingAS
);
119 void InstallLog::EnumerateCurDir(wxString curdir
)
122 wxString curname
, buf
, buf2
, pathcache
;
125 buf
.Printf(wxT("/FilePaths/%s"), curdir
.c_str());
126 pathcache
= logfile
->GetPath();
127 logfile
->SetPath(buf
);
129 contflag
= logfile
->GetFirstGroup(curname
, dummy
);
132 buf
.Printf("%s/%s", curdir
.c_str(), curname
.c_str() );
133 buf2
= buf
; buf2
.Replace(wxT("/"), wxT(PATH_SEP
));
135 EnumerateCurDir(buf
);
136 contflag
= logfile
->GetNextGroup(curname
, dummy
);
139 contflag
= logfile
->GetFirstEntry(curname
, dummy
);
142 if (curname
!= wxT(DIRECTORY_KLUDGE
) )
144 buf
.Printf("%s/%s", curdir
.c_str(), curname
.c_str() );
145 buf2
= buf
; buf2
.Replace(wxT("/"), wxT(PATH_SEP
));
148 contflag
= logfile
->GetNextEntry(curname
, dummy
);
151 logfile
->SetPath(pathcache
);