Exemplo n.º 1
0
/*!	\relates XsFile
	\brief Creates a new text file with name \a filename, contents of existing files will be discarded
	\param filename name of the file to create
	\param writeOnly passing 0 will create the file using "w+t", any other value will create it using "wt"
	\returns XRV_OK if the file was opened, an error otherwise
*/
XsResultValue XsFile_createText(struct XsFile *thisPtr, const struct XsString* filename, int writeOnly)
{
	XsString mode;
	XsString_construct(&mode);
	XsString_resize(&mode, 16);

	if (thisPtr->m_handle != NULL)
		return XRV_ALREADYOPEN;

	if (writeOnly)
	{
		XsString_assign(&mode, 3, "wt");
		thisPtr->m_handle = openFile(filename, &mode);
	}
	else
	{
		XsString_assign(&mode, 4, "w+t");
		thisPtr->m_handle = openFile(filename, &mode);
	}

	if (thisPtr->m_handle == NULL)
		return XRV_OUTPUTCANNOTBEOPENED;
	else
		return XRV_OK;
}
Exemplo n.º 2
0
/*! \relates XsVersion \brief Get a string with the version expressed in a readable format. */
void XsVersion_toString(const XsVersion* thisPtr, XsString* version)
{
	char buffer[256];
	size_t chars;

	if (XsVersion_empty(thisPtr))
		return;

	if (thisPtr->m_build != 0)
		chars = sprintf(buffer, "%d.%d.%d rev %d", thisPtr->m_major, thisPtr->m_minor, thisPtr->m_revision, thisPtr->m_build);
	else
		chars = sprintf(buffer, "%d.%d.%d", thisPtr->m_major, thisPtr->m_minor, thisPtr->m_revision);
	XsString_assign(version, chars, buffer);
	if (thisPtr->m_extra.m_size != 0)
	{
		const char space = ' ';
		XsArray_insert(version, version->m_size-1, 1, &space);	//lint !e64
		XsString_append(version, &thisPtr->m_extra);
	}
}
Exemplo n.º 3
0
/*! \relates XsDeviceId
	\brief Get a string with a readable representation of this device ID. */
void XsDeviceId_toString(const XsDeviceId* thisPtr, XsString* str)
{
	char device[9];
	sprintf(device, "%08X", thisPtr->m_deviceId);	//lint !e534
	XsString_assign(str, 8, device);
}
Exemplo n.º 4
0
/*! \brief This function determines the size of \a src and copies the contents to the object */
void XsString_assignCharArray(XsString* thisPtr, const char* src)
{
	XsString_assign(thisPtr, 0, src);
}