Subversion Repositories spk

Rev

Rev 170 | Rev 183 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 170 Rev 178
Line 115... Line 115...
115
 
115
 
116
	// now lets copy the file
116
	// now lets copy the file
117
	CFileIO CopyFile(f->filePointer());
117
	CFileIO CopyFile(f->filePointer());
118
	if(CopyFile.copy(oDir.file(newDir + "/" + f->filename())))
118
	if(CopyFile.copy(oDir.file(newDir + "/" + f->filename())))
119
	{
119
	{
120
		CLog::logf(CLog::Log_Install, 2, "Original file: %s has been backed up", f->GetNameDirectory(NULL).c_str());
120
		CLog::logf(CLog::Log_Install, 2, "Original file: %s has been backed up", f->getNameDirectory(NULL).c_str());
121
		AddLogEntry(SPKINSTALL_ORIGINAL_BACKUP, f->GetNameDirectory(NULL), errors);
121
		AddLogEntry(SPKINSTALL_ORIGINAL_BACKUP, f->getNameDirectory(NULL), errors);
122
		return true;
122
		return true;
123
	}
123
	}
124
	else
124
	else
125
	{
125
	{
126
		CLog::logf(CLog::Log_Install, 2, "Failed to backup the original file: %s", f->GetNameDirectory(NULL).c_str());
126
		CLog::logf(CLog::Log_Install, 2, "Failed to backup the original file: %s", f->getNameDirectory(NULL).c_str());
127
		AddLogEntry(SPKINSTALL_ORIGINAL_BACKUP_FAIL, f->GetNameDirectory(NULL), errors);
127
		AddLogEntry(SPKINSTALL_ORIGINAL_BACKUP_FAIL, f->getNameDirectory(NULL), errors);
128
		return false;
128
		return false;
129
	}
129
	}
130
}
130
}
131
 
131
 
132
bool COriginalFiles::doBackup(C_File *f, CyStringList *errors)
132
bool COriginalFiles::doBackup(C_File *f, CyStringList *errors)
Line 134... Line 134...
134
	bool backed = false;
134
	bool backed = false;
135
 
135
 
136
	C_File *of = this->_getFile(f);
136
	C_File *of = this->_getFile(f);
137
	if ( of ) {
137
	if ( of ) {
138
		// check if the orignal file is already backed up
138
		// check if the orignal file is already backed up
139
		if ( !CFileIO::Exists(_sDir + "/PluginManager/Original/" + f->GetNameDirectory(NULL).ToString()) )
139
		if ( !CFileIO::Exists(_sDir + "/PluginManager/Original/" + f->getNameDirectory(NULL)) )
140
		{
140
		{
141
			// lets back up the file now
141
			// lets back up the file now
142
			backed = this->backupFile(of, errors);
142
			backed = this->backupFile(of, errors);
143
		}
143
		}
144
	}
144
	}
Line 154... Line 154...
154
		// update the progress
154
		// update the progress
155
		if ( info ) info->UpdateProgress(files, max);
155
		if ( info ) info->UpdateProgress(files, max);
156
		++files;
156
		++files;
157
 
157
 
158
		C_File *f = oNode->Data();
158
		C_File *f = oNode->Data();
159
		CFileIO of(_sDir + "/PluginManager/Original/" + f->GetNameDirectory(NULL).ToString());
159
		CFileIO of(_sDir + "/PluginManager/Original/" + f->getNameDirectory(NULL));
160
		
160
		
161
		if ( of.exists() )
161
		if ( of.exists() )
162
			of.Rename(_sDir + "/" + f->GetNameDirectory(NULL).ToString());
162
			of.Rename(_sDir + "/" + f->getNameDirectory(NULL));
163
 
163
 
164
		delete oNode->Data();
164
		delete oNode->Data();
165
	}
165
	}
166
 
166
 
167
	_lFiles.clear();
167
	_lFiles.clear();
Line 174... Line 174...
174
	bool original = false;
174
	bool original = false;
175
 
175
 
176
	// check if its an original file and restore
176
	// check if its an original file and restore
177
	if ( this->isOriginal(f) )
177
	if ( this->isOriginal(f) )
178
	{
178
	{
179
		CFileIO of(_sDir + "/PluginManager/Original/" + f->GetNameDirectory(NULL).ToString());
179
		CFileIO of(_sDir + "/PluginManager/Original/" + f->getNameDirectory(NULL));
180
		if ( of.exists() )
180
		if ( of.exists() )
181
		{
181
		{
182
			original = true;
182
			original = true;
183
			if ( of.Rename(_sDir + "/" + f->GetNameDirectory(NULL).ToString()) )
183
			if ( of.Rename(_sDir + "/" + f->getNameDirectory(NULL)) )
184
				AddLogEntry(SPKINSTALL_ORIGINAL_RESTORE, f->GetNameDirectory(NULL), errors);
184
				AddLogEntry(SPKINSTALL_ORIGINAL_RESTORE, f->getNameDirectory(NULL), errors);
185
			else
185
			else
186
				AddLogEntry(SPKINSTALL_ORIGINAL_RESTORE_FAIL, f->GetNameDirectory(NULL), errors);
186
				AddLogEntry(SPKINSTALL_ORIGINAL_RESTORE_FAIL, f->getNameDirectory(NULL), errors);
187
 
187
 
188
			CFileIO backupFile(_sDir + "/PluginManager/Original/Replacements/" + f->GetNameDirectory(NULL).ToString());
188
			CFileIO backupFile(_sDir + "/PluginManager/Original/Replacements/" + f->getNameDirectory(NULL));
189
			if ( backupFile.exists() ) backupFile.remove();
189
			if ( backupFile.exists() ) backupFile.remove();
190
 
190
 
191
		}
191
		}
192
	}
192
	}
193
 
193
 
Line 202... Line 202...
202
	uf->setFileType((FileType)data.token(" ", 1).toLong());
202
	uf->setFileType((FileType)data.token(" ", 1).toLong());
203
 
203
 
204
	// Extra files also contain a directory, so make sure we split that up
204
	// Extra files also contain a directory, so make sure we split that up
205
	if (uf->fileType() == FILETYPE_EXTRA )
205
	if (uf->fileType() == FILETYPE_EXTRA )
206
	{
206
	{
207
		uf->SetDir(data.tokens(" ", 2).tokens(":", 2));
207
		uf->setDir(data.tokens(" ", 2).tokens(":", 2));
208
		uf->SetFilename(data.tokens(" ", 2).token(":", 1));
208
		uf->setFilename(data.tokens(" ", 2).token(":", 1));
209
	}
209
	}
210
	else
210
	else
211
		uf->SetFilename(data.tokens(" ", 2));
211
		uf->setFilename(data.tokens(" ", 2));
212
 
212
 
213
	// set the complete filename, GetNameDirectory returns the directory based on the file type
213
	// set the complete filename, GetNameDirectory returns the directory based on the file type
214
	uf->SetFilename(_sDir + "/" + uf->GetNameDirectory(NULL).ToString());
214
	uf->setFilename(_sDir + "/" + uf->getNameDirectory(NULL));
215
 
215
 
216
	_lFiles.push_back(uf);
216
	_lFiles.push_back(uf);
217
}
217
}
218
 
218
 
219
void COriginalFiles::update(bool bForce, const CLinkList<C_File> *pFiles)
219
void COriginalFiles::update(bool bForce, const CLinkList<C_File> *pFiles)
Line 239... Line 239...
239
			Utils::String uString = "Original: ";
239
			Utils::String uString = "Original: ";
240
			uString += Utils::String::Number((long)uf->GetFileType()) + " ";
240
			uString += Utils::String::Number((long)uf->GetFileType()) + " ";
241
			uString += uf->filename();
241
			uString += uf->filename();
242
 
242
 
243
			// add the directory for Extra files
243
			// add the directory for Extra files
244
			if ( uf->GetFileType() == FILETYPE_EXTRA && !uf->GetDir().Empty())
244
			if ( uf->GetFileType() == FILETYPE_EXTRA && !uf->dir().empty())
245
			{
245
			{
246
				uString += ":";
246
				uString += ":";
247
				uString += uf->dir();
247
				uString += uf->dir();
248
			}
248
			}
249
 
249