コード例 #1
0
ファイル: MassStorage.cpp プロジェクト: dc42/RepRapFirmware
/*static*/ void MassStorage::CombineName(const StringRef& outbuf, const char* directory, const char* fileName)
{
	outbuf.Clear();
	size_t outIndex = 0;
	size_t inIndex = 0;

	// DC 2015-11-25 Only prepend the directory if the filename does not have an absolute path or volume specifier
	if (directory != nullptr && fileName[0] != '/' && (strlen(fileName) < 2 || !isdigit(fileName[0]) || fileName[1] != ':'))
	{
		while (directory[inIndex] != 0 && directory[inIndex] != '\n')
		{
			outbuf.Pointer()[outIndex] = directory[inIndex];
			inIndex++;
			outIndex++;
			if (outIndex >= outbuf.Capacity())
			{
				reprap.GetPlatform().MessageF(ErrorMessage, "CombineName() buffer overflow");
				outbuf.copy("?????");
				return;
			}
		}

		if (inIndex > 0 && directory[inIndex - 1] != '/')
		{
			outbuf.Pointer()[outIndex] = '/';
			outIndex++;
		}
		inIndex = 0;
	}

	while (fileName[inIndex] != 0 && fileName[inIndex] != '\n')
	{
		if (outIndex >= outbuf.Capacity())
		{
			reprap.GetPlatform().Message(ErrorMessage, "file name too long");
			outbuf.copy("?????");
			return;
		}
		outbuf.Pointer()[outIndex] = fileName[inIndex];
		inIndex++;
		outIndex++;
	}
	outbuf.Pointer()[outIndex] = 0;
}
コード例 #2
0
ファイル: Grid.cpp プロジェクト: chrishamm/RepRapFirmware
// Read the grid parameters from a string returning true if success
bool GridDefinition::ReadParameters(const StringRef& s)
{
	bool ok = (sscanf(s.Pointer(), "%f,%f,%f,%f,%f,%f,%lu,%lu", &xMin, &xMax, &yMin, &yMax, &radius, &spacing, &numX, &numY) == 8);
	if (ok)
	{
		CheckValidity();
		recipSpacing = 1.0 / spacing;
	}
	else
	{
		isValid = false;
	}
	return ok;
}
コード例 #3
0
void NetworkTransaction::Write(StringRef ref)
{
	Write(ref.Pointer(), ref.strlen());
}
コード例 #4
0
ファイル: Grid.cpp プロジェクト: chrishamm/RepRapFirmware
// Check the parameter label line returning true if correct
/*static*/ bool GridDefinition::CheckHeading(const StringRef& s)
{
	return StringStartsWith(s.Pointer(), HeightMapLabelLine);
}