File diff r27319:ea7c4a418203 → r27320:a815d811abc1
src/fileio.cpp
Show inline comments
 
@@ -285,18 +285,18 @@ FILE *FioFOpenFile(const std::string &fi
 
			}
 
			resolved_name += token;
 
			first = false;
 
		}
 

	
 
		/* Resolve ONE directory link */
 
		for (TarLinkList::iterator link = _tar_linklist[subdir].begin(); link != _tar_linklist[subdir].end(); link++) {
 
			const std::string &src = link->first;
 
		for (const auto &link : _tar_linklist[subdir]) {
 
			const std::string &src = link.first;
 
			size_t len = src.length();
 
			if (resolved_name.length() >= len && resolved_name[len - 1] == PATHSEPCHAR && src.compare(0, len, resolved_name, 0, len) == 0) {
 
				/* Apply link */
 
				resolved_name.replace(0, len, link->second);
 
				resolved_name.replace(0, len, link.second);
 
				break; // Only resolve one level
 
			}
 
		}
 

	
 
		TarFileList::iterator it = _tar_filelist[subdir].find(resolved_name);
 
		if (it != _tar_filelist[subdir].end()) {
 
@@ -663,16 +663,14 @@ bool TarScanner::AddFile(const std::stri
 
	 *      Both the source path and the destination path must NOT contain any further links.
 
	 *      When resolving files at most one directory link is resolved.
 
	 *  2) Links to files:
 
	 *      The destination path must NOT contain any links.
 
	 *      The source path may contain one directory link.
 
	 */
 
	for (TarLinkList::iterator link = links.begin(); link != links.end(); link++) {
 
		const std::string &src = link->first;
 
		const std::string &dest = link->second;
 
		TarAddLink(src, dest, this->subdir);
 
	for (auto &it : links) {
 
		TarAddLink(it.first, it.second, this->subdir);
 
	}
 

	
 
	return true;
 
}
 

	
 
/**
 
@@ -702,22 +700,22 @@ bool ExtractTar(const std::string &tar_f
 
	if (p == std::string::npos) return false;
 

	
 
	filename.replace(p + 1, std::string::npos, dirname);
 
	Debug(misc, 8, "Extracting {} to directory {}", tar_filename, filename);
 
	FioCreateDirectory(filename);
 

	
 
	for (TarFileList::iterator it2 = _tar_filelist[subdir].begin(); it2 != _tar_filelist[subdir].end(); it2++) {
 
		if (tar_filename != it2->second.tar_filename) continue;
 
	for (auto &it2 : _tar_filelist[subdir]) {
 
		if (tar_filename != it2.second.tar_filename) continue;
 

	
 
		filename.replace(p + 1, std::string::npos, it2->first);
 
		filename.replace(p + 1, std::string::npos, it2.first);
 

	
 
		Debug(misc, 9, "  extracting {}", filename);
 

	
 
		/* First open the file in the .tar. */
 
		size_t to_copy = 0;
 
		std::unique_ptr<FILE, FileDeleter> in(FioFOpenFileTar(it2->second, &to_copy));
 
		std::unique_ptr<FILE, FileDeleter> in(FioFOpenFileTar(it2.second, &to_copy));
 
		if (!in) {
 
			Debug(misc, 6, "Extracting {} failed; could not open {}", filename, tar_filename);
 
			return false;
 
		}
 

	
 
		/* Now open the 'output' file. */