Example #1
0
Path FileMessageHandler::FindFilePath(const list<Path>& lps, const Path& f)
{
	// check the current working dir (or full path if supplied) first
	// note that if the file doesn't have a path and it is found in the
	// CWD, the CWD is not returned as part of the path.
	if(CheckIfFileExists(f) == true)
		return f;

	// if the path is absolute there's no point in checking the include paths;
	// given it wasn't found above we can just return an empty path
	if(f.HasVolume() == true)
		return Path();

	Path path(f);

	for(list<Path>::const_iterator i(lps.begin()); i != lps.end(); i++)
	{
		Path path (*i, f);

		if(CheckIfFileExists(path) == true)
			return path;
	}

	// not found so return empty path
	return Path();
}
Example #2
0
	/////////////////////////////////////////////////////////////////////////
	// return true if the path component of file is equal to the path component
	// of path. will also return true if recursive is true and path is a parent
	// of file. does not support relative paths, and will perform case-sensitive
	// comparisons.
	bool vfeUnixSession::TestPath (const Path& path, const Path& file, bool recursive) const
	{
		// we don't support relative paths
		if (path.HasVolume() == false || file.HasVolume() == false)
			return (false);
		if (StrCompare(path.GetVolume(), file.GetVolume()) == false)
			return (false);

		vector<UCS2String> pc = path.GetAllFolders();
		vector<UCS2String> fc = file.GetAllFolders();
		if (fc.size() < pc.size())
			return (false) ;
		for (int i = 0 ; i < pc.size(); i++)
			if (StrCompare(fc[i], pc[i]) == false)
				return (false) ;
		return (fc.size() == pc.size() ? true : recursive);
	}